본문 바로가기

JAVA/기초다지기

논리연산자(OR)

 

package org.opentutorials.javatutorials.eclips;

public class OrDemo {

	public static void main(String[] args) {
		if (true || true) {
			System.out.println(1);
		}
		if (true || false) {
			System.out.println(2);
		}
		if (false || true) {
			System.out.println(3);
		}
		if (false || false) {
			System.out.println(4);
		}
	}

}

 

package org.opentutorials.javatutorials.eclips;

public class LoginDemo4 {

	public static void main(String[] args) {
		String id = args[0];
		String password = args[1];
		if ((id.equals("egoing") || id.equals("k8805") || id.equals("sorialgi"))
				&& password.equals("1111111")) {
			System.out.println("right");
		}else {
			System.out.println("wrong");
	
		}

	}

}

 

 

 

'JAVA > 기초다지기' 카테고리의 다른 글

반복문(While)  (0) 2021.03.05
논리연산자(NOT)  (0) 2021.02.28
논리연산자  (0) 2021.02.28
조건문(switch)  (0) 2021.02.28
조건문(중첩)  (0) 2021.02.28