public class Main {
public static void main(String[] args) {
//1==1이 true, 그것을 !(부정)했기 때문에 false
System.out.println(!(1==1)); //false
//1!=1이 false 그것을 !(부정)했기 때문에 true
System.out.println(!(1!=1));//true
}
}
class Parent{}
class Child extends Parent{}
public class Main {
public static void main(String[] args) {
Parent p = new Parent();
Child c = new Child();
System.out.println("p객체는 Parent가 될수있냐? : "+(p instanceof Parent));//true
System.out.println("p객체는 Child가 될수있냐? : "+(p instanceof Child));//false
System.out.println("c객체는 Parent가 될수있냐? : "+(c instanceof Parent));//true
System.out.println("c객체는 Parent가 될수있냐? : "+(c instanceof Child));//true
}
}
interface Test{
public void go();
}
public class sampleClass{
public static void main(String[] args){
Test test = new Test(){
public void go(){
System.out.println("go");
}
};
test.go
}
}
//일반적인 함수
int min(int x, int y){
return x<y?x:y;
}
//람다표현식
(x,y) -> x<y?x:y;
//가시적으로도 매우 편안하다!
int test;
if(111 > 222){
test=111;
}else{
test=222;
}
//3항 연산자를 사용
int test = (111>222) ? 111 : 222;
T result = switch(arg){
case L1 -> e1;
case L2 -> e2;
default -> e3;
};
//화살표표현을 사용 + expression을 사용 + yield키워드사용
int j = switch(day){
case MONDAY -> 0;
case TUESDAT -> 1;
default ->(
int k = day.toString().length();
int result = f(k);
yield result;
)
};