Language13 JAVA split, Formatting 보호되어 있는 글 입니다. 2023. 7. 22. JAVA Scanner 보호되어 있는 글 입니다. 2023. 7. 21. JAVA 연습문제 (객체 클래스 메서드, split) /* 완전판 물건찍기 */ package hakwon2; import java.util.Scanner; import java.util.ArrayList; // Data 클래스 class Data { // product를 입력하면 '-' 단위로 split 하여 eachinfo 배열에 저장하는 메서드 Name Product String NameProduct(String product) { String[] eachinfo = product.split("-"); String number = eachinfo[0]; String name = eachinfo[1]; String price = eachinfo[2]; String howmany = eachinfo[3]; // 순서대로 split 한 eachinfo의 정.. 2023. 7. 21. JAVA '==' vs 'equals' 보호되어 있는 글 입니다. 2023. 7. 21. JAVA 객체 (6) - a++ 연습문제 package hakwon3; class Plus{ int a; int Plusone(int a) { a++; return a; // 꼭 return a를 해줘야 a++된 값이 출력된다! } } public class Practice { public static void main(String[] args) { Plus firstsample = new Plus(); int firstresult = firstsample.Plusone(31); Plus secondsample = new Plus(); int secondresult = secondsample.Plusone(88); System.out.println(firstresult); System.out.println(secondresult); } } 32.. 2023. 7. 21. JAVA 객체(5) - 메서드에서 빠져나가기 어떤 경우에, 예를 들자면 if ("Lie".equals(Nick)) 와 같이 특정 조건에 해당된다면, 메서드를 즉시 빠져나갈 수 있는 방법이 필요하다. 이때 return을 사용한다. package hakwon3; class Say{ void Nick(String a) { if ("fool!".equals(a)) { return; } System.out.println("Nick said " + a); } } public class Practice { public static void main(String[] args) { Say firstsample = new Say(); firstsample.Nick("fool!"); // 출력되지 않는다. Say secondsample = new Say(); seco.. 2023. 7. 21. 이전 1 2 3 다음