There's no need for this evening, no matter what the compiler
Notepad writing code
1. Installing the JDK 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 by default are int
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 assumes that you see an identifier for an uppercase letter-"class or interface
Interface
Array
logical operators
&& | | ! -
& | You must run both sides of the expression (regardless of the 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) things
Suppose the code needs to run. Then the main function must be required
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, for example, in the form
*
**
***
****
*/
/* 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, in small loops through the rules of the row and column to infer the printing of 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, for example, in the form
*
***
*****
*******
*/
/* 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 a space first. Print again *
*/
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, for example, in the form
*
***
*****
*******
*****
***
*
*/
/* 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 a space first. Print again *
*/
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