c#이랑 크게 다른건 없음
public class Main {
public static void main(String[] args) {
String a = "Man";
int b=6;
//String 값 같은지 비교
if(a.equals(a))
{
System.out.println("Man!");
}
else
{
System.out.println("Woman!");
}
//대소문자 무시
if(a.equalsIgnoreCase("man"))
{
System.out.println("Man!");
}
else
{
System.out.println("Woman!");
}
if(b==0)
{
System.out.println("0입니다.");
}
else
{
System.out.println("0이 아니고 "+b+"입니다.");
}
//반복문을 이용한 원그리기
int N=10;
//원의 방적식
//x^2 + y^2 = r^2;
for(int i= -N; i<=N; i++)
{
for(int j=-N; j<=N; j++)
{
if(i*i+j*j<=N*N)
{
System.out.print("*");
}
else
{
System.out.print(" ");
}
}
System.out.println();
}
}
}
'JAVA > STUDY' 카테고리의 다른 글
6. 반복문과 재귀함수 (팩토리얼, 피보나치) (0) | 2020.09.09 |
---|---|
5. 입력 / 파일 입력 (0) | 2020.09.09 |
3. 자료형(데이터 타입) (0) | 2020.09.08 |
2. 변수, 상수, 연산자 (0) | 2020.09.08 |
1. 개발 환경 설치 및 출력 메서드 (0) | 2020.09.08 |