/*
//c 함수 -> java 메소드
// compile -> ctrl + f11
//syso + ctrl + space (자동완성)
import java.util.*; //입력받기
public class Main {
public static void main(String[] args) {
boolean t; true or false
int a=10;
long b;
double c;
float d;
char e;
String str = "hello"; //char arr[];
System.out.print(str);
System.out.println("hi");
System.out.println("a값은 "+a+"입니다.");
str=str+"hi";
System.out.println(str);
//System.out.printf("%d",a);
//scan
Scanner sc = new Scanner(System.in); //스캐너 생성
// int a = sc.nextInt();
// int b = sc.nextInt();
// System.out.println(a+b);
// System.out.println(a+" "+b);
//double b = sc.nextDouble();
String str = sc.next(); //%s 한 단어
//String str1 = sc.nextLine(); // gets 한 줄
// char arr[] = str.toCharArray();
// System.out.println(arr[0]);
//System.out.println(str.charAt(0)); //not str[0]
for(int i=0;i<str.length(); i++){
System.out.print(str.charAt(i)+" "); //not str[i]
}
+ - * / %
> < >= <= == !=
&& ||
if else , switch case
for while do-while
while(true) {
}
}
}
*/
/*
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(), b = scan.nextInt(), c = scan.nextInt();
if(a + b <= c) {
System.out.print("삼각형아님");
}
else if(a == b && b == c) {
System.out.print("정삼각형");
}
else if(a == b || b == c || a == c) {
System.out.print("이등변삼각형");
}
else if(a*a + b*b == c*c) {
System.out.print("직각삼각형");
}
else {
System.out.print("삼각형");
}
}
}*/
/*
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
System.out.println(((n % 10) * 10 + n / 10) * 2 % 100);
if(((n % 10) * 10 + n / 10) * 2 % 100 <= 50) {
System.out.print("GOOD");
}
else {
System.out.println("OH MY GOD");
}
}
}*/
/*
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(),b = scan.nextInt();
double max = 0;
max = a + b;
if(max < ((a-b > b-a) ? a-b : b-a)) {
max = a-b > b-a ? a-b : b-a;
}
if(max < a * b) {
max = a * b;
}
if(max < ((a/b > b/a) ? a/b : b/a)){
max = ((a/b > b/a) ? a/b : b/a);
}
if(max < ((Math.pow(a, b) > Math.pow(b, a) ? Math.pow(a, b) : Math.pow(b, a)))) {
max = ((Math.pow(a, b) > Math.pow(b, a) ? Math.pow(a, b) : Math.pow(b, a)));
}
System.out.printf("%.6f",max);
}
}
*/
/*
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int h = scan.nextInt(), m = scan.nextInt();
System.out.println(((m + h*60 - 30) + ((m + h*60 - 30) < 0 ? 1440 : 0)) / 60 + " " + ((m + h*60 - 30) + ((m + h*60 - 30) < 0 ? 1440 : 0)) % 60);
}
}*/
/*
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt(), g = scan.nextInt();
System.out.print(g + (90 - t) / 5 + (((90 - t) % 5 == 0) ? 0 : 1));
}
}*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(), b = scan.nextInt(), c= scan.nextInt();
if((a >= b && a >= c && b + c > a) || (b >= a && b >= c && a + c > b) || (c >= a && c >= b && a + b > c)){
System.out.print("yes");
}
else {
System.out.print("no");
}
}
}*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(),b = scan.nextInt(),c = scan.nextInt();
if((a >= b && a <= c )|| (a >= c && a <= b)) {
System.out.print(a);
}
else if((b >= a && b <= c) || (b >= c && b <= a)) {
System.out.print(b);
}
else{
System.out.print(c);
}
}
}
일차원 배열
1. 변수갯수로 선언가능.
2. 선언시 new 어쩌고 꼭 쓰기. 안쓰면 메모리할당안됨!!
3. 정수든 뭐든 배열 길이 알아낼수있음.
+tip 정수-> 문자열 , 문자열->정수 변환 가능
//int[] arr1;
//int arr[5]; (x)
//int arr[] = new int[n];
// arr.length
//int a = 50;
//String str = Integer.toString(a); //정수->문자열
String str = "1234";
int a = Integer.valueOf(str); //문자열->정수
System.out.println(a+1);
문자열끼리 비교할때는 == 절대 안됨!!!!!!!
String s1 = "hello";
String s2 = "jello";
if(s1==s2) (x)
if(s1.equals(s2)) (o)
System.out.println(s1.compareTo(s2)); 사전식비교
*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int max = 1;
while(n > 0){
max *= n;
n--;
}
System.out.print(max);
}
}*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(),k = 0;
for(int i = 1; i <= n; i++) {
k += i * (n - i + 1);
}
System.out.print(k);
}
}*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
if(n % 7 == 0){
System.out.print("multiple");
}
else{
System.out.print("not multiple");
}
}
}
*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(), b = scan.nextInt();
int max = 0;
for(int i = a; i <= b; i++) {
if(i % 2 == 0)
max -= i;
else
max += i;
}
System.out.print(max);
}
}*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(), b = scan.nextInt();
int n = 3,max = 0;
while(n <= b){
if(n >= a && n <= b){
max += n;
}
n += 3;
}
System.out.println(max);
}
}
*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int arr[] = new int[n];
for(int i = 0; i < n; i++) {
arr[i] = scan.nextInt();
}
for(int i = 0; i < n; i++)
{
System.out.print((i+1) +": ");
for(int j = 0; j < n; j++){
if(j != i){
if(arr[i] == arr[j]){
System.out.print("= ");
}
else if(arr[i] > arr[j]){
System.out.print("> ");
}
else {
System.out.print("< ");
}
}
}System.out.println();
}
}
}*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
char str[] = scan.nextLine().toCharArray();
for(int i = 0; i < str.length; i++) {
if(str[i] >= 'A' && str[i] <= 'Z'){
System.out.print((char)(str[i] + 32));
}
else if(str[i] >= 'a' && str[i] <= 'z'){
System.out.print((char)(str[i] - 32));
}
else{
System.out.print(str[i]);
}
}
}
}
*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
char str[] = scan.nextLine().toCharArray();
for(int i = 0; i < str.length; i++) {
if(str[i] != ' '){
System.out.print(str[i]);
}
}
}
}
*/
/*
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int arr[][] = new int[n][n];
for(int i = 0; i < n; i++) {
arr[i][0] = scan.nextInt();
}
for(int i = 0; i < n; i++) {
for(int j = 0; j <= i; j++) {
if(i >= 1 && j >= 1)
arr[i][j] = arr[i][j-1] - arr[i-1][j-1];
System.out.print(arr[i][j] + " ");
}System.out.println();
}
}
}
1. 클래스
2. 상속
3. 제네릭
4. GUI
5. event1
6. event2
7. graphic
8. thread
메소드 = 함수
클래스 틀 (생성자, 필드, 메소드)
객체 틀로 만들어낸 물체
class Fish
{
//필드
int size;
String name, material;
//생성자 (객체 생성시 필드의 초깃값을 설정)
Fish(){ //기본생성자
this(10,"noname","empty"); //자신의 다른 생성자 호출 가능
// size=10;
// name="noname";
// material="empty";
}
Fish(int size){
this.size=size;
}
Fish(int size, String name, String material){
this.size=size;
this.name=name;
this.material = material;
}
//메소드
void view() {
System.out.println("크기 : "+size + ", 이름 : "+name+", 내용물 : "+material);
}
}
class Main{
public static void main(String[] args) {
Fish b; //레퍼런스 변수
b = new Fish(); //객체생성
b.size=10;
Fish b = new Fish();
b.size=10;
b.name="빵1";
b.material = "팥";
b.view();
Fish b1 = new Fish(100,"슈붕","슈크림");
b1.view();
System.out.println(b1.size + " "+b1.name+" "+b1.material);
}
}
*/
/*
public class Main {
String title;
String author;
void show() {System.out.println(title + " " + author); }
public Main() {
this("","");
System.out.println("생성자 호출됨");
}
public Main(String title) {
this(title, "작자미상");
}
public Main(String title, String author) {
this.title = title;
this.author = author;
}
public static void main(String[] args) {
Main littlePrince = new Main("어린왕자", "생텍쥐페리");
Main loveStory = new Main("춘향전");
Main emptyBook = new Main();
Main x = littlePrince;
littlePrince = loveStory;
loveStory = x;
littlePrince.show();
}
}*/
/*
class Samp {
int id;
public void Samp(int x) {
this.id = x;
}
public void Samp() {
System.out.println("생성자 호출");
this(0);
}
}
class Main {
int id;
public Main(int x) {
this.id = x;
}
public Main() {
this(0);
System.out.println("생성자 호출");
}
}
객체 배열 생성은 두 번 거쳐야한다.
1. 레퍼런스의 배열 c
2. 객체를 만들어서 레퍼런스 객체에 할당
overloading vs overriding
오버로딩 vs 오버라이딩
생성자 오버로딩
메소드 오버로딩 (공존) - 이름은 같고 매개변수만 달라
*/
/*
class Circle{
int r;
public Circle(int r) {this.r=r;}
void view() {
System.out.println("반지름은 "+r+"입니다.");
}
void view(int n) {
for(int i=0;i<n;i++) view();
}
}
class Main{
public static void main(String[] args) {
Circle c[] = new Circle[5];
for(int i=0;i<5;i++) {
c[i] = new Circle(i);
System.out.println(c[i].r);
}
}
}*/
//241.1
/*
class TV{
int year,inch;
String name;
public TV(String name, int year, int inch) {
this.year = year;
this.inch = inch;
this.name = name;
}
void show() {
System.out.println(name + "에서 만든 " + year + "년형 " + inch +"인치 TV");
}
}
class Main{
public static void main(String[] args) {
TV myTV = new TV("LG", 2017, 32);
myTV.show();
}
}
*/
/*
import java.util.*;
class Grade {
int math, science, english;
public Grade(int math, int science, int english) {
this.math = math;
this.science = science;
this.english = english;
}
public int average() {
return (math + science + english)/3;
}
}
public class Main{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("수학, 과학, 영어 순으로 3개의 점수 입력>>");
int math = scanner.nextInt();
int science = scanner.nextInt();
int english = scanner.nextInt();
Grade me = new Grade(math, science, english);
System.out.println("평균은 " + me.average());
scanner.close();
}
}
*/
//242.3
/*
import java.util.*;
class Song {
String title, artist, country;
int year;
public Song() {
}
public Song(String title, String artist, String country, int year) {
this.title = title;
this.artist = artist;
this.country = country;
this.year = year;
}
public void show() {
System.out.println(year + "년 " + country + "국적의 " + artist + "가 부른 "+ title);
}
}
class Main {
public static void main(String[] args) {
Song c = new Song("Dancing Queen","ABBA","스웨덴",1978);
c.show();
}
}
*/
//242.4
/*
import java.util.*;
class Rectangle{
int x, y, width, height;
public Rectangle(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public int square() {
return width*height;
}
public void show() {
System.out.println("(" + x + "," + y + ")에서 크기가 " + width + "x" + height +"인 사각형");
}
public boolean contains(Rectangle n) {
if(this.x < n.x && this.y < n.y && n.x + n.width < this.x + this.width && n.y + n.height < this.y + this.height)
return true;
else
return false;
}
}
public class Main{
public static void main(String[] args) {
Rectangle r = new Rectangle(2, 2, 8, 7);
Rectangle s = new Rectangle(5, 5, 6, 6);
Rectangle t = new Rectangle(1, 1, 10, 10);
r.show();
System.out.println("s의 면적은 " + s.square());
if(t.contains(r)) System.out.println("t는 r을 포함합니다.");
if(t.contains(s)) System.out.println("t는 s를 포함합니다.");
}
}
*/
//243.5
/*
import java.util.Scanner;
class Circle {
private double x, y;
private int radius;
public Circle(double x, double y, int radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public void show() {
System.out.println("(" + x + "," + y + ")" + radius);
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Circle c[] = new Circle[3];
for(int i=0; i<c.length; i++) {
System.out.print("x, y, radius >>");
double x = scanner.nextDouble();
double y = scanner.nextDouble();
int radius = scanner.nextInt();
c[i] = new Circle(x, y, radius);
}
for(int i=0; i<c.length; i++) c[i].show();
scanner.close();
}
}*/
//244.6
/*
import java.util.Scanner;
class Circle {
private double x, y;
private int radius;
public Circle(){
}
public Circle(double x, double y, int radius) {
this.x = x;
this.y = y;
this.radius = radius;
}
public int getR() {
return radius;
}
public void show() {
System.out.println("가장 면적인 큰 원은 (" + this.x + "," + this.y + ")" + this.radius);
}
}
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Circle c[] = new Circle[3];
int k = -1;
for(int i=0; i<c.length; i++) {
System.out.print("x, y, radius >>");
double x = scanner.nextDouble();
double y = scanner.nextDouble();
int radius = scanner.nextInt();
c[i] = new Circle(x, y, radius);
if(k == -1 || c[k].getR() < c[i].getR()){
k = i;
}
}
c[k].show();
scanner.close();
}
}
*/