Вы находитесь на странице: 1из 4

����������

{int-�����
byte(-128...127)
short(-32768...32767
int(������ ��������)
long(����� ����� !!!)}
double-�������
float= 23f - ������� (���������� � ����� f)
String-������
char-������
boolean-Tree or False

����������
(/**/)-������� �����������
//-�������� �����������

�������������� ��������
˸����
+ - ���
- - �����
/ -������
* - ��������
^ - �������
% - ������� ��� �������
++ - ��� 1
-- - ����� 1
�������
Math.pow(b,2)-���������� � �������
Math.sqrt()-������ ����������
Math.tan(x*y)-�������
Math.sin()-�����
Math.cos()-�������

���� � ����������(������ ��������)

import java.util.Scanner; //��������� ���������� �������


Scanner num = new Scanner(System.in); //������ ����� ������(���������, �����) ����
Scanner "num"
int i; //������ ������ ���������
i = num.nextItn(); //�������� �� ����������� ��������(int) � ����������� ���
���������� "i"
i = num.nextLine(); //�������� �� ����������� ��������(string) � ����������� ���
���������� "i"
i = num.nextDouble(); //�������� �� ����������� ��������(double) � ����������� ���
���������� "i"
System.out.ptintln(i); //������� ���������� �������� � ����������

�������� ���������
������
if() - ����
else() - ��������� ���� �� ����������� if
&& - �
|| - ���
== - �����
!= - �� ����
< - ������
<= - ������ ���� �����
> - ������
>= - ������ ���� �����
�������
1) if(i!=10){
System.out.printl("i is not 10"); //���� ����-�� ��������� i �� ����� 10,
�� �� ����� ���������: i is not 10
}

2) if(i!=10){
System.out.println("i is not 10"); //���� ����-�� ��������� i �� ����� 10,
�� �� ����� ���������: i is not 10
} else{
System.out.println("i is unknown"); //� ���� ����-�� ��������� �� ��������
������� if, ������ �� ����� ���������:i is unknown
{

3) if(i!=10){
System.out.println("i is not 10"); //���� ����-�� ��������� i �� ����� 10,
�� �� ����� ���������: i is not 10
}
else if (i >100){
System.out.println("i ����� 100"); // � ���� ����-�� ��������� �� ��������
������� if, ������ ��������� ������� else (i > 100), � ���� �� ������, ��
���������: i ������ 100
}
else{
System.out.println("i is unknown");//���� �� � ������ ������� ��
���������, �� �� ����� ���������:i is unknown
}

4) else(i>100) && else(g<1000){


System.out.println("it's tree");// ���� i>100 � g<1000, �� �� �����
���������: it's tree
}

5) else(i>100) || else(g<1000){
System.out.println("it's okey");// ���� i>100 ��� g<1000, �� �� �����
���������: it's okey
}

6) int a; //������ ��������� �


switch (a);{ // ���������� ��� ��������� �� ���������
case 12: //���� � = 12, �� ������� �� �����: �=12, ���� ��� , �� ��������� �
���������� case
System.out.println("a=12");
break; //�� ��������� �������� case, ���� a=12
case 573: //���� � = 573, �� ������� �� �����: �=573, ���� ��� , ��
��������� � ���������� case
System.out.println("a=573");
break; //�� ��������� �������� case, ���� a=573
case 24: //���� � = 24, �� ������� �� �����: �=24, ���� ��� , �� ��������� �
���������� case
System.out.println("a=24");
break; //�� ��������� �������� case, ���� a=24
default: //�����������, ���� �� ���� �� case �� ��������, ������� �� �����:
i �� ����� 12, 573 � 24
System.out.println("i �� ����� 12, 573 � 24");
}

�����
�������:
-=10 - �������� �� 10
+=12 - ��������� �� 12
*= 30 - �������� �� 30
/=50 - ������ �� 50

1) for(int=0; i<100;i++);{ // ��������� ���� � ������ ���� ��������� i=0, ����


����� ������, ���� i<100, �� ������ ����� ���� � i ����� ��������� +1
Sustem.out.println("��������� �����"+i); //����� ��������� ���������, ���� ��
��������� ����
}

2) int a; // ������ ��������� �����


while(a<15);{ // ���� ����� ��������� ���� a<15 ;
System.out.println(a); // ������� �� ����� �
a++; // ����� ������� ����� ��������� 1
}

3)
int y ; //������ ��������� �����
do{
While(y<1);{ //���� ���������� ���� ���� ������� �� ������, �� ������ 1 ���
System.out.println("y");} //����� ���������� �� �����
}

������� (�������� ������� ������ ��������� � 0)

1)���������� ������

int [] arr=new int[3] {56, 76, 89}; // ������ ������ "arr" , ��������� �������
��������� � ������� "[3]" , ��������� ������� ������� "{56, 76, 89}
System.out,print(arr[1]);// ������� ������ ������� �������
for(i=0;i<4;i++){// ������ ���� ����� ������� ����� ��� ������� �����
System.out,print(arr[i]);
2)����������� ������ - ��� ������, � ������ ������� ��������� �� ���� ������
int [2][2] arr_2 = new int[3][3];{//������ ������ arr_2, ������[]-��� ����������
�����, ������[]- ��� ���������� �������� � ����� ������
{23,34,45}// ������ � ������ ������
{12,13,16}// ������ �� ������ ������
{56,78,91}// ������ � ������� ������
};
arr_2[1][1]=289// ����������� ������[1] ����� �� ������� �������[1],�
����������� ��� ����� �������� 289 ;
for(int r =0; r<3;r++){
for(int g=0; g<3:g++){
System.out.println(arr_2[r][g]);// ����� ���� ��������� �������

�������(������)
1)�� ���������� �������
public static void main(String[] args){// public-������ ��� ������
��������(�������� �� ����� ������), void- �������� ��� ������ ����������,
�� �������� ������� �� ������, (String[] args)-������ ��� ������ �������� �������
������� ����������, static - �������� ��� ������ ����������� ������������ ������
func(34, 56);// ������� �����, �� �������� � �������� � �������� �����(�����)
}
public static void fanc(int a, int b){// �������� ��� ���������� "fanc" ����
����� �����, a � b -��� ��������� ����������
}

2)���������� ������
public static void main(Strings[] args){
int tam = con(56;60);//������ ��������� tam, ������ ����� ����� �����������
������� ������� con;
System.out.println(tam);//������� ��������� ���������
}
public static int con(int a; int b);{// �������� ��� ���������� "con" ���� �����
�����, a � b -��� ��������� ����������
int res;// ����� ���� ���� ���������
res=a+b;// ������������ ��� �������� � ����� ��������� �� ���������� �������
��������
return res;// ���������� ���������
}
�������� ������� � ��������

FileWriter nFile = new FileWriter("test.txt");


nFile.write("Hello World");
nFile.close();

Вам также может понравиться