Skip to content

Add files via upload #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions Operators.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import java.sql.SQLOutput;

public class Operators {
public static void main(String[] args) {

// 산술 연산자

int a = 10;
int b = 20;
String c = "abc";

System.out.println(a + c); // 문자열이 아닌 데이터와 함께 사용하면 문자열로 변환됨

double d = 10;
double e = 20;
System.out.println(d / e); // 소수 형태로 사용하면 계산 결과가 출력됨

System.out.println(a + b);
System.out.println(a - b);
System.out.println(a * b);
System.out.println(a / b); // 정수 형태로 사용하면 나눗셈의 몫이 계산됨
System.out.println(a % b);

// 비교 연산자

int i = 5;
int j = 8;

System.out.println(a > b);
System.out.println(a > b);

System.out.println(a >= b);
System.out.println(a >= b);

// = 대입연산자, == 비교연산자
System.out.println(a == b);
System.out.println(a != b);

// 논리 연산자

int l = 3;
int m = 3;
int n = 5;

// and(&&) - 교집합
System.out.println(n > l && n > m); // true && true

// or(||) - 합집합
System.out.println(n > l || n < m); // true || false

// not(!) - 여집합
System.out.println(!true);
System.out.println(!false);

// 대입 연산자

int k = 1;
double price = 12.5;

// 증감 연산자
// k++; // k = k + 1
// k--; // k = k - 1
// System.out.println(a++);
// System.out.println(a);
System.out.println(++a);




}
}