After a month's naked resignation from the company, the original job was VB, but now I want to be engaged in java. When looking for a job, I always need some project experience, which is somewhat unhappy. All languages have the same experience.
General, I don't believe that Java is so difficult? Give yourself time to study. Stick to self-study for a month and see how much your efforts really help. This study is based on the core technology of java.
Beginning with the 9th edition, write an article for each chapter. If you write incorrectly, please give your advice.
"Most powerful languages like Java aren't easy to learn." Chapter 1 begins by giving me a kick-off. Now that you say that, I'll show you! Chapter 1 and 2 are
Talk about the concept of java, development, skip it!
1.helloworld
According to convention, learning a language begins with a simple program: hellowrold;java class names begin with capitals, with multiple initials capitalized. Class represents a class, java's
The foundation is composed of classes, which contain attributes and methods. The main method, like the main method in C language, is the entry point for each program to run; each class can only have 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 }
2. Data type
Shaping: byte:1 byte; (1 byte 8 binary 00000, range: - 2^8 to 2 ^ 8 - 1) short: 2 byte int: 4 bytes; long 8 bytes;
Floating point type: used to represent a type with decimal points; float: 4 bytes; double: 8 bytes;
Char type: char: single character type; "A", "a" and so on, as well as escape character "/n" line break, etc.
boolean type: FALSE true; true and false!
3. Variables
In java, each variable belongs to a type that precedes the variable. For example, int i; at the same time, each variable must be assigned an initial value, otherwise when variables are used
Mistakes will be reported.
4. Operator
+-*/% Addition, subtraction, multiplication, division and residue; ++, - self-increasing and self-decreasing operators; & and, | or, ~non, ^ exclusive or; & and, | or;
5. Mandatory Type Conversion
For example, when double converts to int, the compiler will think that there is a mistake if the decimal digit after double converts to int, and then the forced conversion is needed, such as: int i=(int) 4.3;
6. String class
@Test /** * Testing common String methods; String is implemented by arrays, so modifying a String is equivalent to creating a new String */ public void testString(){ String s="hello "; //Judge whether it is empty System.out.println(s.isEmpty()); //Determine whether strings are equal System.out.println(s.equals("Hello")); //Determine whether strings are equal, case-insensitive System.out.println(s.equalsIgnoreCase("Hello")); //Returns a string with subscript 1 System.out.println(s.charAt(1)); //Returns the length of the string System.out.println(s.length()); //All capital letters System.out.println(s.toUpperCase()); //All lowercase letters System.out.println(s.toLowerCase()); //Remove the beginning or end of the string System.out.println(s.trim()); //Intercept strings from the beginning to the end of Subscripts-1 Intercept System.out.println(s.substring(1,3)); }
7. Control statement
@Test public void testControl(){ int i = 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) { case 0: System.out.println("switch:"+i); break;//If not break Execute the sequence case 1: System.out.println("switch:"+i); break; default: System.out.println(i); break; } }
8. Arrays
@Test public void testArray(){ int a[]={6,4,7,6,3,8,9}; //foreach loop for(int j:a){ System.out.println(j); } Arrays.sort(a);//Array Sorting, Using Quick Sorting Method int b[]=Arrays.copyOf(a, a.length); for(int j:b){ System.out.println("copy"+j); } }