Learning Resources E -book articlesFrom the foundation to the project actual combat massive Video tutorial Resources chapterI. Electronic Book Resources Daquan
1. Java Basics2. Java EE3. Front Page related4. Database related5. Java Virtual Machine Related6.
Learning Resources E -book articles
From the foundation to the project actual combat massive Video tutorial Resources chapter
I. Electronic Book Resources Daquan
1. Java Basics2. Java EE3. Front Page related4. Database related5. Java Virtual Machine Re
Java --- 12 --- multi-thread exercise: Ticket Selling --- data sharing
Do an exercise: sell tickets to small programs to achieve data sharing.
Let's first create a thread and run it alternately with the main thread.
This is relatively simple:
Let's just inherit the Thread class:
class MyThread extends Thread{ private int num = 150; private String name
/* Exercise: "Kbashbdjsgfwhofihbfkwejhfiubjzfhaads" gets the number of occurrences of the letter in the string. Want to print results: A (3) B (4) d (2) ... The results show that each letter has a corresponding number of times. , indicating that there is a mapping between the characters and the number of times. Note: When a mapping relationship is found, you can select the Map collection. Because the map collection stores the mapping relationship. Why
Today, a friend in the group asked such an exercise, I simply paste the code here, the next time a friend needs to come here to see.Using knowledge points: Arrays, collections, IO streamsDescription of the problem: read the data into memory, for example, in a TXT file that you see, and then count the number of each number in the column except 0 (put in a map) and sort by the data size of the column.Code:Package Com.test;import Java.io.bufferedreader;i
With the support of many friends, I was determined to write a Java book this year. No matter whether I receive your attention, I will write every piece of content with my best efforts.
In fact, there are a lot of books in Java at present. In the opinion of experts, 8 or 9 of the 10 books are spam books, or they are not well written or really wanted, or copy it.
Java First pair programming exercise
Study Notes
infix expression converted to suffix expression
If a number is encountered, we will output it directly.
If a non-number is encountered, if the stack is empty or the symbol is an opening parenthesis or the top element of the stack is parentheses, directly into the stack.
If a closing parenthesis is encountered, the stack is persist
Test (); Define an integer array int[] scores={89,-23,64,91,119,52,73,-45,78,168}; System.out.println ("Top three of the exam results:"); Call the method of the class, output the result Test.result (scores); } Define the method to finish sorting and output the top three functions public void result (int[] scores) {//Use the sort () method of the array Arrays.sort (scores);//Initialize variable int count=0; for (int i=scores.length-
("Account Number:"+a.getzhanghao () +"balance is ="+A.getyue ()); }}
3.Write Java Applications. first, define a clock class--clock, which consists of three int typesMember variables represent hours, minutes, seconds, and a construction method for three member variables (hours, minutes, Seconds)For initialization, There is also a member method show () to display the time of the clock object. second, RedefineA main class,--testclass, creates obje
);//system.out.println ("maxday=" +maxday); System.out.println ("t \ t two \ \ Three \ Four \ five \ t six"); int flag = 0;for (int i=1;i============================================================Summarize:-------------------the common methods of GregorianCalendar class are summarized------------------------------------getactualmaximum (calendar.date)----This method is not well mastered, but also need more memoryget (Calendar.day_of_week)----This method This acquisition is the day of the weekSe
1. Get line number function case for custom class simulation LineNumberReader2. Code implementation:(1)Mybufferedreader. Java:1 Packagecn.itcast_08;2 3 Importjava.io.IOException;4 ImportJava.io.Reader;5 6 /*7 * Simulate BufferedReader's readline () function with reader8 * 9 * ReadLine (): reads one line at a time, determines whether to end with newline characters, returns only content, and does not return newline charactersTen */ One Public classM
Java --- 12 --- multi-thread exercise: Ticket Selling --- data sharing,
Do an exercise: sell tickets to small programs to achieve data sharing.
Let's first create a thread and run it alternately with the main thread.
This is relatively simple:
Let's just inherit the Thread class:
class MyThread extends Thread{ private int num = 150; private String name;
. Name.compareto (s.name): num; the //the name is the same length and content, does not mean the same age, so you have to continue to judge the age + intnum3 = Num2 = = 0? This. Age-s.age:num2; - returnnum3; $ } $}(2)Treesetdemo. Java:1 Packagecn.itcast_06;2 3 ImportJava.util.TreeSet;4 5 /*6 * Requirements: Please follow the name of the length of the order7 */8 Public classTreesetdemo {9 Public Static voidMain (stri
(); }}A run we found that the ticket sales process has been implemented, has achieved data sharing. What's going on?Why is it possible to implement the Runnable interface?So first think about this question:Why pass the subclass object of the Runnable interface as the actual parameter to the constructor of the thread class?Because the object that the custom run method belongs to is the subclass object of the Runnable interface,The Run method runs after the thread is started, but the new threa
Java Object instanceof keyword exercise: judge whether the set of the same person is sorted by age. If the same age is sorted by name in alphabetical order, Comparator,
Package com. swift; public class Same_Person_Test {public static void main (String [] args) {/** Object determines whether the Object is the same Person */Person per1 = new Person ("zhangsan", 30 ); person per2 = new Person ("lisi", 27); Per
character, string is an operation on a sequence of characters, and StringBuffer is an operation on a string of characters.Statement of the 1.CharacterPublic final class Character extends Object implements Serializable,comparableHow to construct 2.CharacterPublic Character (char) {}3. Common methodsToString () method4. Normally, when we use characters, we sometimes need to use the characters of the original data typechar ch = ' a '; char Unichar = ' \u039a '; char[] Chararray = {' A ', ' B ', '
people met in the number 2, the benchmark number 3 and this 2 exchange, get a new array 2 1 0 3 7 9 3 5, the 3 as a split point, the entire array is divided into two parts, the left 2 1 0 and the right 7 9 3 Repeat the above steps to continue sortingThe Java code is as follows: Public classQuickSort { Public Static voidMain (string[] args) {//TODO auto-generated Method StubQuickSort QS=NewQuickSort (); int[] score = {10,9,8,7,6,5,4,3,2,1}; Qs.quickso
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.