Java Learning Note 2015-6-5

Source: Internet
Author: User

You don't need any compilers this evening.
Notepad writing code
1. JDK Installation Configuration
2. JDK JRE Relationship
3. Basic syntax constant volume data type logical operator Flow control statement
4. Minor Practice Questions
5. Homework after class


Notes:


Data type

Integral type:
BYTE 1 byte 8 Bit 00000000

Short 2 bytes


int 4 bytes All integer constants in Java are int by default

Long 8 bytes


Floating point type:
Float 4 bytes

float f= 1.1F;

Double 8 bytes All decimal Constants in Java are double by default


Character type:
Char


Boolean type:
Boolean


Reference type:


Class String Double JAVA If you see an identifier-"class or interface" with the first letter capitalized

Interface
Array

logical operators


&& | |    ! -


& | Both expressions must be executed (ignoring any situation)




True && false, False


true | | False-True




Loop for nesting from the inside out, one layer at a layer of analysis






Summarize:


1. What are the corresponding lengths of the eight basic data types to convert each other?


2, the installation and configuration of the JDK know the reason why


3, the Process Control statement Basic code writing


4, all the code must be in the class inside the class can not directly write (non-property and method) of things

If the code needs to be executed, then the main function must be




For () {} is typically used for fine-grained knowledge of the start and end


while (true) {if () {break;}} when the number of cycles cannot be predicted


do{} while ();


Next lesson: TXT Classes and objects


Practice:


*
**
***
****


*
***
*****
*******


*
***
*****
*******
*****
***

*

/*


* Choose Good to learn Java jobs
* Instructor: Bear
* Student Cao Kun
* 2015-6-6


*/






/* Requirements: Print as Shape


*
**
***
****


*/


/* Analysis


Print 4 rows 4 columns with loop nesting implementation
First line: Space 3 stars 1
Second line: Space 2 stars 2
Line three: space 1 Stars 3
Line four: space 0 stars 4


Two methods are implemented
1, a cycle nested two small loop first hit the space and then hit the star
2, a loop only nested a small loop, small loop in the rules of the row and column to determine whether to print a space or to print a star


*/
public class printstar1{


public static void Main (String args[]) {


for (int i=0;i<4;i++) {


for (int j=0;j<3-i;j++) {


System.out.print ("");


}


for (int k=0;k<=i;k++) {

System.out.print ("*");


}

System.out.println ();


}

System.out.print ("---------------------------------------");

System.out.println ();

for (int i=0;i<4;i++) {

for (int j=4;j>0;j--) {

if (j-i>1) {

System.out.print ("");

}else{


System.out.print ("*");


}

}

System.out.println ();


}

}


}




/*


* Choose Good to learn Java jobs
* Instructor: Bear
* Student Cao Kun
* 2015-6-6


*/






/* Requirements: Print as Shape
*
***
*****
*******


*/


/* Analysis:


First line: Space 3 stars 1
Second line: Space 2 stars 3
Line three: space 1 stars 5
Line four: space 0 stars 7


I increment 0 1 2 3
How J and I control print out


Print space First, then print *


*/




public class printstar2{


public static void Main (String args[]) {


for (int i=0;i<4;i++) {

Print Space first
for (int j=0;j<3-i;j++) {


System.out.print ("");

}

Print again *
for (int k=0;k<i*2+1;k++) {


System.out.print ("*");

}

System.out.println ();


}

}




}

/*


* Choose Good to learn Java jobs
* Instructor: Bear
* Student Cao Kun
* 2015-6-6


*/


/* Requirements: Print as Shape
*
***
*****
*******
*****
***
*


*/


/* Analysis:


First line: Space 3 stars 1
Second line: Space 2 stars 3
Line three: space 1 stars 5
Line four: space 0 stars 7
Line five: space 1 stars 5
Line Six: Space 2 stars 3
Line seventh: space 3 stars 1


I increment 0 1 2 3 4 5 6
How J and I control print out


Print space First, then print *


*/


Start let ' s go


public class printstar3{


public static void Main (String args[]) {

for (int i=0;i<4;i++) {//First 4 rows

for (int j=0;j<3-i;j++) {


System.out.print ("");
}


for (int k=0;k<i*2+1;k++) {


System.out.print ("*");
}


System.out.println ();


}


for (int i=0;i<3;i++) {//re-print after 3 lines

for (int j=0;j<=i;j++) {


System.out.print ("");
}


for (int k=0;k<5-i*2;k++) {


System.out.print ("*");
}


System.out.println ();


}





}




}










Java Learning Note 2015-6-5

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.