Презентация на тему EPAM JavaLab. Basic syntax

Naming conventions © 2015. EPAM Systems. All Rights Reserved. Package package com.epam.lab.droids; Classes & Interfaces class BattleDroid Variables double energyLevel; Methods void destroyEnemy(Droid enemy) Constants final static int MAX_DROIDS_IN_SQUAD;
EPAM JavaLab © 2015. EPAM Systems. All Rights Reserved. Basic syntax Naming conventions © 2015. EPAM Systems. All Rights Reserved. Package package com.epam.lab.droids; Classes & Interfaces Keywords © 2015. EPAM Systems. All Rights Reserved. Identifiers © 2015. EPAM Systems. All Rights Reserved. JediKnight jediName jedi_name _R2D2_port $strangeVar JediKnight ≠ Comments // C++ style © 2015. EPAM Systems. All Rights Reserved. /* C style */ Statement © 2015. EPAM Systems. All Rights Reserved. String a = ”” + b + Blocks © 2015. EPAM Systems. All Rights Reserved. String a = ”” + b + Primitives © 2015. EPAM Systems. All Rights Reserved. boolean char byte float double short int Primitives © 2015. EPAM Systems. All Rights Reserved. integral floating int decVal = 26; // Primitives vs. Wrappers © 2015. EPAM Systems. All Rights Reserved. int -> Integer  long References © 2015. EPAM Systems. All Rights Reserved. Droid c3po = new TranslationDroid(); c3po.translate(text); *c3po; References vs primitives © 2015. EPAM Systems. All Rights Reserved. public class Droid{ Instantiation of an object © 2015. EPAM Systems. All Rights Reserved. Droid c3po = new Operators expr++ expr-- ++expr --expr +expr -expr * / % + - String s = “Hello ”; String name = “Skywalker”; int num = 2; s if (droidsAmount > MAX_DROIDS_IN_SQUAD) 	createAnotherSquad(); else if (droidsAmount < MIN_DROIDS_IN_SQUAD)  dismissSquad(); else 	deploySquad(); switch (expr1) {  	case constant2: 		//statements 		break; 	case constant3: 		//statements 		break; 	default: 		//statements for(int i=0; i for(Droid enemyDroid : enemyDroidsList) 	//do something with enemy droid }  Loops - foreach © while(droidsAmount > 3){ squad.attack(enemy); }  Loops - while © 2015. EPAM Systems. All Rights do{  squad.attack(enemy); }while(droidsAmount > 3)   Loops - do - while © 2015. break continue return label:  Loops - flow control © 2015. EPAM Systems. All Rights Q&A © 2015. EPAM Systems. All Rights Reserved. PRACTICE © 2015. EPAM Systems. All Rights Reserved. Task © 2015. EPAM Systems. All Rights Reserved. Compile and run java app from console.

Слайды и текст этой презентации

Слайд 1 EPAM JavaLab
© 2015. EPAM Systems. All Rights Reserved.
Basic syntax

EPAM JavaLab© 2015. EPAM Systems. All Rights Reserved.Basic syntax

Слайд 2 Naming conventions
© 2015. EPAM Systems. All Rights Reserved.
Package
package com.epam.lab.droids;
Classes & Interfaces
class

Naming conventions© 2015. EPAM Systems. All Rights Reserved.Packagepackage com.epam.lab.droids;Classes & Interfacesclass BattleDroidVariablesdouble energyLevel;Methodsvoid destroyEnemy(Droid enemy)Constantsfinal
BattleDroid

Variables
double energyLevel;

Methods
void destroyEnemy(Droid enemy)

Constants
final static int MAX_DROIDS_IN_SQUAD;


Слайд 3 Keywords
© 2015. EPAM Systems. All Rights Reserved.

Keywords© 2015. EPAM Systems. All Rights Reserved.

Слайд 4 Identifiers
© 2015. EPAM Systems. All Rights Reserved.
JediKnight
jediName
jedi_name
_R2D2_port
$strangeVar
JediKnight ≠ jediKnight

Identifiers© 2015. EPAM Systems. All Rights Reserved.JediKnightjediNamejedi_name_R2D2_port$strangeVarJediKnight ≠ jediKnight

Слайд 5 Comments
// C++ style
© 2015. EPAM Systems. All Rights Reserved.
/* C style

Comments// C++ style© 2015. EPAM Systems. All Rights Reserved./* C style *//** Javadoc */Self Documented
*/

/** Javadoc */

Self Documented


Слайд 6 Statement
© 2015. EPAM Systems. All Rights Reserved.
String a = ”” +

Statement© 2015. EPAM Systems. All Rights Reserved.String a = ”” + b + 32 + droid.getEnergy();
b + 32 + droid.getEnergy();

Слайд 7 Blocks
© 2015. EPAM Systems. All Rights Reserved.
String a = ”” +

Blocks© 2015. EPAM Systems. All Rights Reserved.String a = ”” + b + 32 +
b + 32 + droid.getEnergy();

public void doSomething(int b){

}


Слайд 8 Primitives
© 2015. EPAM Systems. All Rights Reserved.
boolean
char
byte
float
double
short
int
long
primitives
integral
floating

Primitives© 2015. EPAM Systems. All Rights Reserved.booleancharbytefloatdoubleshortintlongprimitivesintegralfloating

Слайд 9 Primitives
© 2015. EPAM Systems. All Rights Reserved.
integral
floating
int decVal = 26; //

Primitives© 2015. EPAM Systems. All Rights Reserved.integralfloatingint decVal = 26; // The number 26, in
The number 26, in decimal
int octVal = 032; // The number 26, in octal
int hexVal = 0x1a; // The number 26, in hexadecimal

long longVal = 5L;
short shortVal = 4s;

float floatVal = 5.4f;
double doubleVal = 0.32;


Слайд 10 Primitives vs. Wrappers
© 2015. EPAM Systems. All Rights Reserved.
int -> Integer

Primitives vs. Wrappers© 2015. EPAM Systems. All Rights Reserved.int -> Integer long -> Long byte

long -> Long

byte -> Byte

short -> Short

float -> Float

double -> Double


Слайд 11 References
© 2015. EPAM Systems. All Rights Reserved.
Droid c3po = new TranslationDroid();
c3po.translate(text);
*c3po;
&c3po;

References© 2015. EPAM Systems. All Rights Reserved.Droid c3po = new TranslationDroid();c3po.translate(text);*c3po;&c3po;

Слайд 12 References vs primitives
© 2015. EPAM Systems. All Rights Reserved.
public class Droid{

References vs primitives© 2015. EPAM Systems. All Rights Reserved.public class Droid{ 	private int energy =

private int energy = 0; //energy is a primitive.
private Blaster blaster;// blaster is a null reference //to a Blaster object.
public Droid(int power, int speed, int energy) {
this.energy = energy;
blaster = new Blaster(power, speed);
// blaster is now // initialized and points // to the Blaster object // located on the heap.
}

public static void main(String args[ ]){
Droid droid = new Droid(3,6,5);// droid is a reference.

}

}

Слайд 13 Instantiation of an object
© 2015. EPAM Systems. All Rights Reserved.
Droid c3po

Instantiation of an object© 2015. EPAM Systems. All Rights Reserved.Droid c3po = new TranslationDroid();
= new TranslationDroid();

Слайд 14


Operators
expr++ expr--
++expr --expr +expr -expr
* / %
+ -
> >>>
< >

Operatorsexpr++ expr--++expr --expr +expr -expr* / %+ -> >>>< > = instanceof== !=?:= *= /=
<= >= instanceof
== !=
?:
= *= /= %= += -= <<= >>= >>>= &= ^= |=

Expressions

© 2015. EPAM Systems. All Rights Reserved.

Logical operators
! // not
|| // or
&& // and

Bits operators
| // or
^ // xor
& // and
~ // inversion


Слайд 15
String s = “Hello ”;
String name = “Skywalker”;
int num = 2;
s

String s = “Hello ”;String name = “Skywalker”;int num = 2;s = s + ”to
= s + ”to “ + name + ” and his “ +
+ num + ” droids.”;
System.out.println(s);

/* “Hello to Skywalker and his 2 droids.”
will be printed. */

Strings

© 2015. EPAM Systems. All Rights Reserved.


Слайд 16
if (droidsAmount > MAX_DROIDS_IN_SQUAD)
createAnotherSquad();
else if (droidsAmount < MIN_DROIDS_IN_SQUAD)
dismissSquad();
else
deploySquad();

If -

if (droidsAmount > MAX_DROIDS_IN_SQUAD)	createAnotherSquad();else if (droidsAmount < MIN_DROIDS_IN_SQUAD) dismissSquad();else	deploySquad(); If - else© 2015. EPAM Systems.
else

© 2015. EPAM Systems. All Rights Reserved.


Слайд 17
switch (expr1) {

case constant2:
//statements
break;
case constant3:
//statements
break;
default:
//statements
break;

}

Switch
© 2015. EPAM Systems. All Rights

switch (expr1) {	case constant2:		//statements		break;	case constant3:		//statements		break;	default:		//statements		break;} Switch© 2015. EPAM Systems. All Rights Reserved.
Reserved.

Слайд 18 for(int i=0; i

for(int i=0; i
All Rights Reserved.

Слайд 19 for(Droid enemyDroid : enemyDroidsList)
//do something with enemy droid
}
Loops - foreach
©

for(Droid enemyDroid : enemyDroidsList)	//do something with enemy droid} Loops - foreach© 2015. EPAM Systems. All
2015. EPAM Systems. All Rights Reserved.

Слайд 20 while(droidsAmount > 3){
squad.attack(enemy);
}
Loops - while
© 2015. EPAM Systems. All Rights

while(droidsAmount > 3){squad.attack(enemy);} Loops - while© 2015. EPAM Systems. All Rights Reserved.
Reserved.

Слайд 21 do{
squad.attack(enemy);
}while(droidsAmount > 3)

Loops - do - while
© 2015. EPAM

do{ squad.attack(enemy);}while(droidsAmount > 3) Loops - do - while© 2015. EPAM Systems. All Rights Reserved.
Systems. All Rights Reserved.

Слайд 22 break
continue
return
label:
Loops - flow control
© 2015. EPAM Systems. All Rights Reserved.

breakcontinuereturnlabel: Loops - flow control© 2015. EPAM Systems. All Rights Reserved.

Слайд 23 Q&A
© 2015. EPAM Systems. All Rights Reserved.

Q&A© 2015. EPAM Systems. All Rights Reserved.

Слайд 24 PRACTICE
© 2015. EPAM Systems. All Rights Reserved.

PRACTICE© 2015. EPAM Systems. All Rights Reserved.

Слайд 25 Task
© 2015. EPAM Systems. All Rights Reserved.
Compile and run java app

Task© 2015. EPAM Systems. All Rights Reserved.Compile and run java app from console.Write program, which
from console.
Write program, which will pass requirements:
- User enter the interval (for example: [1;100]);
- Program prints odd numbers from start to the end of interval and even from end to start;
Program prints the sum of odd and even numbers;
Program build Fibonacci numbers: F1 will be the biggest odd number and F2 – the biggest even number, user can enter the size of set (N);
Program prints percentage of odd and even Fibonacci numbers;
Object-Oriented analysis and design.

  • Имя файла: epam-javalab-basic-syntax.pptx
  • Количество просмотров: 24
  • Количество скачиваний: 0