Chapter 2 Tutorial java2 basic data types and arrays

Identifier

  1. Letters, underscores, dollar symbols, numbers
  2. The first character can not be a number
  3. Keywords can not make
  4. You can not make true, false, null

Keyword

abstract assert boolean break byte case catch char class const continue default do double else enum extends final finallu float for goto if implements import instanceof int interface long native new package private protected public return short static stricfp super switch synchronized this throw throws transient try void volatile while

Basic data types

Logic Type:

boolean

Integer type:

  • a byte byte 8 bits -128 ~ 127 (byte) -12, a range of constant values ​​byte int type constants
  • short two bytes
  • int four bytes -2 ^ 31 to 2 ^ 31-1
  • eight bytes long

Character Types

  • char two bytes
    in single quotes the Unicode character char ch1 = '\ n' A may also represent '\ u0041' hexadecimal escape

Floating-point type

  • float 4 bytes, suffix f / F save significant digits 8
  • double 8 bytes

Type Conversion

== low level "high level autochanger
High Level ==" low level using a type conversion operator

Input and output data

Scanner reader  = new Scanner(System.in);

reader object to call the following methods nextInt ()

Array

1. Declare
a float CAT [];
char CAT [] [];
specified number of array elements in the array declaration allowed java brackets
2. calculation made for the new allocation element array
CAT = new a float [. 4];
int A [] [] = new int [ 3] [6]
array reference variable belongs, the address of the first element of the array variable stored in an array

3.
a.lenth is 3, i.e., of length two-digit number of one-dimensional array of
points for each element of the array to create a default value, float-type 0.0

Published 14 original articles · won praise 0 · Views 97

Guess you like

Origin blog.csdn.net/weixin_38235865/article/details/104518849