To start studying this language , first you need to know what data is capable of handling , what chance that data management provides that enforcement tools to control what we can and user interaction offers.
Basic types of data blocks in which are divided java basic types are: Integer : There are four types that allow us to represent integers. Floating point : There are two types used to represent real data. Characters : A type that allows us to represent characters in any world language. Logic : A type to represent logical values.
Whole Name Size Range 64 bits long - 9.233.372.036.854.775.808L to 9,233,372,036,854,775,808 int 32 -2,147,483,648 to 2,147,483,647 bits short 16 bits -32,768 to 32,767 byte 8 bits -128 to 127
Floating Point Name Size Range float 32 bits ± 3.40282347E +38 F double 64 bits ± 1.79769313486231570E +308
Sequence Characters Description ? Backspace Tab New line Carriage return ' Single quote " Double quote Backslash
Logic Java to represent logical values used , the type boolean, which allows you to take two values : true and false.
Wrapper Wrappers type float int Integer long Long short Short Float double Double byte boolean Boolean Byte Character char void Void
Literals and literal constants type int 123 Comments All integers are int default 123L long must indicate an L char ' to ' Single quotation 5.9F float may also use exponential notation double 1.8E9 7.9 All actual default is double. It can end with an A boolean true true and false are the only valid values String " hello" Double Quotes
The easiest variable of storing information is to use variables. Before using any variable , regardless of type , you need to declare .
Declaration The declaration of these variables can be done in any part of a class or method. The way to declare indicates the name and type of the same but may be accompanied by information as the initial value or the Declaration of more variables of the same type . type identifier [ = value] [ , identifier [ = value ] ... ] , int i = 0 , j , double d = Math.sqrt ( i * 5);
Scope and lifetime of variables The scope occurs within a code block . The lifetime is the time between the declaration of the variable and its destruction. { Int a , a = 9; { int b = a +1 ; } a = 10; }
Basic use of string literals is possible to define text string with double quotes quoting around , print System.out.println ( ) and even concatenate these strings using the + operator . System.out.println ( " Hello " + "world" ) ; also be done in this way : String a, b , a = " Hello " , b = "world" ; String c = a + b ; System.out . println ( c);
Array is a homogeneous dataset occupy contiguous memory locations that can be referenced by a unique name.
Statement one-dimensional arrays of the reference declaration of the array is done by specifying the type of the array followed by [ ] , then comes the name of the variable. int [ ] a; Once you have the reference , you have to allocate memory to store the array, this will use the new operator. New is used when you want to create a new element dynamically within programs . a = new int [10 ] ;
Access to a one-dimensional array by reference is accessed and a unique index , the index of the array is an integer between 0 and size -1. int a [] = { 1,2,3 } ; System.out.println ( b [ 1]) will print two
Declaring a two dimensional array A multidimensional array is an array of arrays and is defined as follows : int [ ] [ ] table = new int [2 ] [3 ] ; But only must indicate the number of rows , then can allocate memory for the rest independently. int [ ] [ ] table = new int [2 ] [ ] table [ 0 ] = new int [ 3], Table [1 ] = new int [3 ] ;
Accessing a multidimensional array is in the same manner as the one-dimensional arrays , it only raises a new set of brackets with the index of the next dimension. System.out.println (Table [1 ] [1 ] ) ;
We will have operators from operators to perform simple arithmetic operations to bit -level operations , which are: arithmetic, relational , logical, bitwise , assignment , the ternary operator precedence .
Arithmetic Operators Operator Description + Addition - Reta * Multiplication / Division % Modulus + + Increment - Decrement
Relational Operators Operator Description == Equal ! = > Greater than < less than> = Greater than or equal < = Less than or equal
Logical Operators Operator Description & AND | OR ^ XOR && shortcut | | OR shortcut ! NOT
Bitwise Operators Operator Description ~ NOT & AND | OR ^ XOR >> Shift right Shift right >>> unsigned << Shift left
Assignment Operators Operator Description ~ NOT Addition and assignment + = - = Subtract and Assignment * = Multiplication and assignment / = Division and allocation % = Modulo and assignment & = AND and assignment | = OR and XOR allocation and assignment ^ = << = left shift and assign >> = right shift and assignment >>> = Shift right unsigned assignment
The operator centenary The? : Is the ternary operator . You can replace an if- then-else . Its syntax is: exp1 ? exp2 : exp3 ; Where exp1 is a Boolean expression .
Operator Operator Precedence Associativity ( ) [ ] . left to right + + - ! + ( unary ) - ( unary ) ( ) ( cast) new left to right * / % left to right + - left to right left to right >>>>> << >> = < = > instanceof left to right == ! = left to right & left to right left to right | left to right && left to right | | left to right ? : Left to right = + = - = * = / = % = & = | == << = >> = >>> = left to right
There Flow Control conditional statements and loops. Conditional statements : if-else and switch. Loops: while, for, do-while
If-else statement is used to make decisions, we can decide between two possible options exclusive. The syntax is: if ( expression ) statement -1 [ else statement -2]
Switch statement is used to replace nested if . The syntax is: switch ( expression) {case value1 : statement; ..... [break ;] ... [default : statement; sentence; ] }
In this loop while loop a series of statements are repeated while a certain condition is met . One feature is that the loop body is executed 0 or N times. The syntax is: while ( expression ) statement
Loop is equivalent to a while loop with the difference that can make assignments and changes in the control variable within the loop. The syntax is : for ( exp1 , exp2 ; exp3 ) statement can omit any of the three expressions , but the semicolons must remain .
Do-while loop checking the loop condition is evaluated after executing the body The syntax is : do statement while ( expression) ; Runs 1 to N veces.i
Basic types of data blocks in which are divided java basic types are: Integer : There are four types that allow us to represent integers. Floating point : There are two types used to represent real data. Characters : A type that allows us to represent characters in any world language. Logic : A type to represent logical values.
Whole Name Size Range 64 bits long - 9.233.372.036.854.775.808L to 9,233,372,036,854,775,808 int 32 -2,147,483,648 to 2,147,483,647 bits short 16 bits -32,768 to 32,767 byte 8 bits -128 to 127
Floating Point Name Size Range float 32 bits ± 3.40282347E +38 F double 64 bits ± 1.79769313486231570E +308
Sequence Characters Description ? Backspace Tab New line Carriage return ' Single quote " Double quote Backslash
Logic Java to represent logical values used , the type boolean, which allows you to take two values : true and false.
Wrapper Wrappers type float int Integer long Long short Short Float double Double byte boolean Boolean Byte Character char void Void
Literals and literal constants type int 123 Comments All integers are int default 123L long must indicate an L char ' to ' Single quotation 5.9F float may also use exponential notation double 1.8E9 7.9 All actual default is double. It can end with an A boolean true true and false are the only valid values String " hello" Double Quotes
The easiest variable of storing information is to use variables. Before using any variable , regardless of type , you need to declare .
Declaration The declaration of these variables can be done in any part of a class or method. The way to declare indicates the name and type of the same but may be accompanied by information as the initial value or the Declaration of more variables of the same type . type identifier [ = value] [ , identifier [ = value ] ... ] , int i = 0 , j , double d = Math.sqrt ( i * 5);
Scope and lifetime of variables The scope occurs within a code block . The lifetime is the time between the declaration of the variable and its destruction. { Int a , a = 9; { int b = a +1 ; } a = 10; }
Basic use of string literals is possible to define text string with double quotes quoting around , print System.out.println ( ) and even concatenate these strings using the + operator . System.out.println ( " Hello " + "world" ) ; also be done in this way : String a, b , a = " Hello " , b = "world" ; String c = a + b ; System.out . println ( c);
Array is a homogeneous dataset occupy contiguous memory locations that can be referenced by a unique name.
Statement one-dimensional arrays of the reference declaration of the array is done by specifying the type of the array followed by [ ] , then comes the name of the variable. int [ ] a; Once you have the reference , you have to allocate memory to store the array, this will use the new operator. New is used when you want to create a new element dynamically within programs . a = new int [10 ] ;
Access to a one-dimensional array by reference is accessed and a unique index , the index of the array is an integer between 0 and size -1. int a [] = { 1,2,3 } ; System.out.println ( b [ 1]) will print two
Declaring a two dimensional array A multidimensional array is an array of arrays and is defined as follows : int [ ] [ ] table = new int [2 ] [3 ] ; But only must indicate the number of rows , then can allocate memory for the rest independently. int [ ] [ ] table = new int [2 ] [ ] table [ 0 ] = new int [ 3], Table [1 ] = new int [3 ] ;
Accessing a multidimensional array is in the same manner as the one-dimensional arrays , it only raises a new set of brackets with the index of the next dimension. System.out.println (Table [1 ] [1 ] ) ;
We will have operators from operators to perform simple arithmetic operations to bit -level operations , which are: arithmetic, relational , logical, bitwise , assignment , the ternary operator precedence .
Arithmetic Operators Operator Description + Addition - Reta * Multiplication / Division % Modulus + + Increment - Decrement
Relational Operators Operator Description == Equal ! = > Greater than < less than> = Greater than or equal < = Less than or equal
Logical Operators Operator Description & AND | OR ^ XOR && shortcut | | OR shortcut ! NOT
Bitwise Operators Operator Description ~ NOT & AND | OR ^ XOR >> Shift right Shift right >>> unsigned << Shift left
Assignment Operators Operator Description ~ NOT Addition and assignment + = - = Subtract and Assignment * = Multiplication and assignment / = Division and allocation % = Modulo and assignment & = AND and assignment | = OR and XOR allocation and assignment ^ = << = left shift and assign >> = right shift and assignment >>> = Shift right unsigned assignment
The operator centenary The? : Is the ternary operator . You can replace an if- then-else . Its syntax is: exp1 ? exp2 : exp3 ; Where exp1 is a Boolean expression .
Operator Operator Precedence Associativity ( ) [ ] . left to right + + - ! + ( unary ) - ( unary ) ( ) ( cast) new left to right * / % left to right + - left to right left to right >>>>> << >> = < = > instanceof left to right == ! = left to right & left to right left to right | left to right && left to right | | left to right ? : Left to right = + = - = * = / = % = & = | == << = >> = >>> = left to right
There Flow Control conditional statements and loops. Conditional statements : if-else and switch. Loops: while, for, do-while
If-else statement is used to make decisions, we can decide between two possible options exclusive. The syntax is: if ( expression ) statement -1 [ else statement -2]
Switch statement is used to replace nested if . The syntax is: switch ( expression) {case value1 : statement; ..... [break ;] ... [default : statement; sentence; ] }
In this loop while loop a series of statements are repeated while a certain condition is met . One feature is that the loop body is executed 0 or N times. The syntax is: while ( expression ) statement
Loop is equivalent to a while loop with the difference that can make assignments and changes in the control variable within the loop. The syntax is : for ( exp1 , exp2 ; exp3 ) statement can omit any of the three expressions , but the semicolons must remain .
Do-while loop checking the loop condition is evaluated after executing the body The syntax is : do statement while ( expression) ; Runs 1 to N veces.i
WHAT YOU NEED TO START PROGRAM IN JAVA