From the company bare one months, the original work is to do VB, now want to engage in Java, when looking for a job always want what project experience, how much some uncomfortable, all languages have a total
The continuity, I do not believe that Java is so difficult? Give yourself some time to learn. Insist on self-study for one months to see how much effort you have made. This study is based on the Java core technology
The 9th edition begins, each reading chapter writes an article, if writes the wrong, please advise.
"A powerful language like Java is mostly not easy to learn", the first chapter gives me a scare ... If you say so, I'll learn to show it to you! The 12th chapter is
Talk about the concept of Java, the development of this, skip!
1.helloworld
As a rule, learn the beginning of a language, a simple program: The Hellowrold;java class name begins with a capital letter, and multiple letters are capitalized. class represents a category, Java's
The base is made up of classes that contain properties and methods. The main method, like the main method of C, is the entry for each program, and each class can have only one class.
public. In addition, the Java code ends with a semicolon at the end of each sentence;
1 Public class HelloWorld {2 3 Public Static void Main (string[] args) {4 5 System.out.println ("HelloWorld"); 6 }
View Code
2. Data type
Shaping: byte:1 bytes; (1 bytes 8 Binary 00000000, Range: -2^8 to 2^8-1) short:2 bytes Int:4 bytes; long 8 bytes;
Floating-point type: Used to denote a type with a decimal point; float:4 bytes; double:8 bytes;
Char type: Char: Single character type, "a", "a" and so on, with escape character "/n" line wrapping, etc.;
Boolean type: FALSE true; True and False!
3. Variables
Each variable belongs to a type (type) in Java, and the type precedes the variable. For example, int i; At the same time, each variable must be assigned an initial value, or the variable will be used
Will error;
4. Operators
+-*/%: subtraction remainder; ++,--self-increment decrement operator;& with, | Or, ~ Non, ^ xor; && with, | | Or
5. Forcing type conversions
For example, double to int type, the following decimal place may be gone, the compiler thinks it is wrong; this time it is necessary to cast, for example: int i= (int) 4.3;
6. String class
@Test/*** Test string common methods; string is implemented by an array, so modifying a string is equivalent to creating a new string*/ Public voidteststring () {String s= "Hello"; //determines whether the emptySystem.out.println (S.isempty ()); //determine if strings are equalSystem.out.println (S.equals ("Hello")); //determine if strings are equal, not case-sensitiveSystem.out.println (S.equalsignorecase ("Hello")); //returns a string with the subscript 1System.out.println (S.charat (1)); //returns the length of a stringSystem.out.println (S.length ()); //All uppercase LettersSystem.out.println (S.touppercase ()); //Letter All LowercaseSystem.out.println (S.tolowercase ()); //Remove the beginning or end of a stringSystem.out.println (S.trim ()); //intercept a string from the beginning of the subscript to the end-1 interceptSystem.out.println (s.substring (1,3)); }
7. Control statements
@Test Public voidTestControl () {inti = 0 ; for(; i<10;i++) {System.out.println (i); } while(i>0) {System.out.println (i--); } if(i>0) {System.out.println ("I>0"); }Else{System.out.println ("I<=0"); } Switch(i) { Case0: System.out.println ("Switch:" +i); Break;//If the order is executed without break Case1: System.out.println ("Switch:" +i); Break; default: System.out.println (i); Break; } }View Code
8. Arrays
@Test Public voidTestarray () {inta[]={6,4,7,6,3,8,9}; //foreach Loop for(intj:a) {System.out.println (j); } arrays.sort (a);//array sorting, using the fast sorting method intb[]=arrays.copyof (A, a.length); for(intj:b) {System.out.println ("Copy" +j); } } View Code
Learn Java (a) Java basic syntax from scratch