编程知识 cdmana.com

Java basic learning

Java Basics :

Statement :

1) Learning as an individual , If offended , Inform quick delete !

2) Don't want to mislead , If there is a mistake , please don 't refuse to offer your kind advice !

Basic concepts :

data type :

  1. Computer memory unit Please check the basics of computer
  2. java Data types in

data type

keyword

Memory footprint

Value range

Integer types

byte

1

-128~127

short

2

-32768~32767

int( Default )

4

-2 Of 31 Second party to 2 Of 31 Power -1

long

8

-2 Of 63 Second party to 2 Of 63 Power -1

Floating point type

float

4

negative :-3.402823E+38 To -1.401298E-45 Positive numbers : 1.401298E-45 To 3.402823E+38

double( Default )

8

negative :-1.797693E+308 To -4.9000000E-324 Positive numbers :4.9000000E-324 To 1.797693E+308

Character type

char

2

0-65535

Boolean type

boolean

1

true,false

Variable :

identifier :

Identifier is the name used by the user when programming , Used to give a class 、 Method 、 Variable 、 Constants, etc .

Java The composition rules of bid identifier :

  1. By letter 、 Numbers 、 Underline “_”、 Dollar symbol “$” form , The first character cannot be a number .
    • Out of commission java As an identifier .
  2. Identifiers are case sensitive ( Case sensitive ).

Java Naming convention of bid identifier :

  1. Little hump style name : Variable name 、 Method name
    • Initial lowercase , Start with the second word and capitalize each word .
  2. Big hump style name : Class name
    • The first letter of each word is capitalized .
  3. in addition , The best way to name an identifier is to know the meaning of the name
    • for example :username、studentNumber etc. .

Type conversion :

  1. Automatic type conversion
  2. Cast

Operator :

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day2/demo/Relationship.java

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day2/demo/countSum.java

data input :

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day2/demo/inputDate.java

Flow control statement :

  1. Process control statement classification
  2. Sequential structure
  3. Branching structure if sentence
    1. if Sentence format 1
    2. if Sentence format 2
    3. if Sentence format 3

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day2/demo/Process_control.java

switch sentence :

  1. switch Sentence structure
  2. practice

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day3/switchCycle.java

for loop :

  1. for Loop structure
  2. for Circulation practice

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day3/forCycle.java

while loop :

  1. while structure
  2. while Circulation practice

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day3/whileCycle.java

Loop details :

  1. do-while Loop structure
  2. The difference between the three cycles
    1. The difference between the three cycles
      • for Circulation and while Circulation first determines whether the condition is true , Then decide whether to execute the loop body ( Judge before you execute )
      • do…while The loop executes the loop body once , Then judge whether the condition is true , Whether to continue to execute the loop body ( Execute before judge )
    2. for Circulation and while The difference between
      • The self increasing variable controlled by conditional control statement , Because of belonging for In the grammatical structure of a loop , stay for At the end of the cycle , You can't be visited again
      • The self increasing variable controlled by conditional control statement , about while Circularly speaking, it does not belong to its grammatical structure , stay while At the end of the cycle , This variable can still be used
    3. Dead cycle ( Infinite loop ) Three formats of
      1. for(;?{}
      2. while(true){}
      3. do {} while(true);
  3. Jump control statement
  4. A nested loop

Random:

  1. Random Generate random numbers
  2. Random practice

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day3/random.java

Array :

Code link :https://github.com/xbhog/JavaBasis/blob/master/JavaStudy/src/day4/array.java

Method :

Complete project code :

Github:https://github.com/xbhog/JavaBasis

thank : If it helps you , I hope you can have one star, thank !!

Participation of this paper Tencent cloud media sharing plan , You are welcome to join us , share .

版权声明
本文为[xbhog]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201225111921846s.html

Scroll to Top