s+=a;
int a = Integer.MAX_VALUE
int a;
a=(3>2)?10:20; //String s; 문자열로도 가능
배열 기본형
int[]a = new int[10];
a[0]=100;
//배열은 0부터
int[]b = {10,20,30};
System.out.println(b[0]);
int[]apple = new int[8];//배열 사용방법 1
int[]banana = {10,20,30,40,1,2,3,4};//배열 사용방법 2
System.out.println(apple.length);//배열의 크기
System.out.println(banana.length);
for (int i = 0; i < banana.length; i++) {
System.out.println(banana[i]);//배열갯수 셀 필요가없다.
switch 문
switch(a){
case 10:
break;
default:
break;
}
package practice1;
public class practice1 {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
System.out.println("5"+"*"+i+"="+(5*i));
}
}
}
package practice1;
public class practice1 {
public static void main(String[] args) {
int s = 0;
for (int i = 0; i <= 100; i++) {
s +=i;
}
System.out.println(s);
}
}
package practice1;
import java.util.Random;
public class practice1 {
public static void main(String[] args) {
int a = (new Random().nextInt(100));
System.out.println(a);
}
}
package practice1;
import java.util.Random;
public class practice1 {
public static void main(String[] args) {
for (int i = 0; i < 10; i++) {
int a = (new Random().nextInt(100));
System.out.println(a);
}
}
}
package practice1;
import java.util.Random;
public class practice1 {
public static void main(String[] args) {
int s=0;
for (int i = 0; i < 5; i++) {
int a = (new Random().nextInt(10));
s +=a;
System.out.println(a);
}
System.out.println(s);
}
}
package practice1;
import java.util.Random;
public class practice1 {
public static void main(String[] args) {
int s=0;
for (int i = 0; i < 10; i++) {
int a = (new Random().nextInt(100));
int q = a%10;
int d = a/10;
int p = q+d;
s =+p;
if(d==0)
{
System.out.println("0"+a+" "+s);
}else
System.out.println(a+ " "+s);
}
}
}
package practice1;
import java.util.Random;
public class practice1 {
public static void main(String[] args) {
for (int i = 0; i < 26; i++) {
System.out.println((char)('A'+i));
}
}
}
(char) 강제형변환 65->A 아스키코드
package practice1;
import java.util.Random;
import java.util.Scanner;
public class practice1 {
public static void main(String[] args) {
int input = new Scanner(System.in).nextInt();
System.out.println(input);
}
}
package practice1;
import java.util.Random;
import java.util.Scanner;
public class practice1 {
public static void main(String[] args) {
for (int i = 0; i < 127; i++) {
System.out.println((char)i);
}
}
}
package practice1;
import java.util.Random;
import java.util.Scanner;
public class practice1 {
public static void main(String[] args) {
int a=10;
int b = 200;
System.out.println(a+ " "+b);
int t;
t=a;//t는 10
a=b;//a는 200
b=t;//t는 10이었으므로 b=10
System.out.println(a+ " "+b);
}
}
package practice1;
public class practice1 {
public static void main(String[] args) {
int a=10,b;
int c=10,d;
b = a++;
d=++c;
System.out.println(b+" "+d);
//++은 따로쓰고 한번더 더해주는게 좋다고함
//ex) x=a++; b=x+c;
}
}
'비트 장기 > JAVA' 카테고리의 다른 글
7/16 복습 (0) | 2018.07.17 |
---|---|
7/16 수업(class 복습, 예제) (0) | 2018.07.16 |
7/13 복습 (0) | 2018.07.15 |
7/13 배움(클래스 복습떄 용어정리하기) (0) | 2018.07.13 |
7/12 복습 (0) | 2018.07.13 |
댓글