ImportJava.util.Scanner; Public classHelloWorld {Static Final Doublepi=3.14; Static intx=125; /*** Document Comment, program name: HelloWorld * Development time: 2016-03-07 * hehe **/ Public Static voidMain (string[] args) {//TODO auto-generated Method StubSystem.out.println ("I can learn java!!."); System.out.println ("Good BYE liuliu~"); //variablesString var = "Hi world!"; System.out.println (VAR); intX=521,y=123; floati=1.23f; Doublej=100.123d; SYSTEM.OUT.PRINTLN (x+y+i*pi+j); System.out.println (helloworld.x); CharStr= ' a '; CharStr1= ' \ n '; CharStr2= ' \u2605 '; System.out.print (str); System.out.print (STR1); System.out.print (STR2); //operatorScanner scan=NewScanner (system.in); System.out.print ("Please enter the value of variable a"); LongA=Scan.nextlong (); System.out.print ("Please enter the value of variable B"); Longb=Scan.nextlong (); System.out.println ("A=" + A + "b=" +b); System.out.println ("Perform variable swaps, displacement can only be integral"); A=a^b; b=b^A; A=a^C; System.out.println ("A=" + A + "b=" +b); String Check= (a% 2 ==0)? " A is even ":" A is odd "; SYSTEM.OUT.PRINTLN (check); //Forcing type conversions intLiua= (int) 78.33; LongLiub= (Long) 17.8; intLiuc= (int) ' A '; Shortliud=521; byteLiue= (byte) Liud;//byte maximum of 127, resulting in data overflowSystem.out.println ("A:" +liua+ ", B:" +liub+ ", C:" +liuc+ ", D:" +liud+ ", E:" +liue); //determine if the year entered is a leap yearsSystem.out.print ("Please enter a year: The rules for leap years can be divisible by 4 or 400 and not divisible by 100. )"); LongYear=Scan.nextlong (); if(Year% 4 ==0 && year%!! = 0 | | Year% 400 ==0) {System.out.println ( year+ "is a leap year"); } Else{System.out.println ( year+ "is not a leap year. "); } } }
Java Language Basics _ Learning Notes