Language/java

package day09; import java.util.ArrayList; import java.util.Iterator; public class ListTest { public static void main(String[] args) { ArrayList list = new ArrayList(); list.add("홍길동"); list.add("임꺽정"); list.add("일지매"); list.add("둘리"); String str = "abcd"; int strLength = str.length(); System.out.println(strLength); int length = list.size(); System.out.println(length); for(int i =0; i
package day08; public class ShapeTest { public static void main(String[] args) { Shape[] arr = new Shape[3]; arr[0] = new Circle(3); arr[1] = new Triangle(2,5); arr[2] = new Square(10,20); //그리다 메서드 출력 for(int i =0; i
package Practice; import java.util.Scanner; public class LoginTest { public static void main(String[] args) { Student[] students = new Student[3]; students[0] = new Student("aaa"); students[1] = new Student("bbb"); students[2] = new Student("ccc"); //학생 로그인 하기 //학생은 자신의 번호와 이름을 입력하여 시스템에 로그인한다. //학생은 자신의 번호와 이름을 알고있다. (전제) //1. 학생의 자신의 번호와 이름을 입력할 수 있어야 한다. //--> Scanner 객체를 이용해서 next...()를 이용해서..
package inheritance; public class MouseTest5 { public static void main(String[] args) { Mouse[] arr = new Mouse[3]; //참조자료형 arr[0] = new Mouse(); arr[1] = new WheelMouse(); arr[2] = new OpticalMouse(); for(int i=0;i
package inheritance; public abstract class Transportation { //추상클래스 public abstract void go(); //추상메서드 }​ package inheritance; public class GoBusanTest { public static void main(String[] args) { Bus bus = new Bus(); Train train = new Train(); BusanTravel busan = new BusanTravel(); //Transportation T = new Transportation(); busan.goBusan(bus); busan.goBusan(train); //bus.goBus(); //train.goTrain(..
package day05; public class Student02 { String name; int money; static int studentNum; Student02(){ studentNum++; } public Student02(String name, int money){ this.name = name; this.money = money; } public void takebus(Bus02 Bus02){ Bus02.takePassenger(1500); money = money-1500; } void studentInfo() { System.out.println("학생 이름 : "+name+ " 남은돈 : "+ money+" 학생번호 : "+ studentNum); } }​ package day05..
package day05; public class UnitB { //UnitA unitA = new UnitA("AAA"); String type; int energy; UnitB(String type){ this.type = type; energy = 10; } public void attack(UnitA UnitA){ //attack 메소드가 실행되면 unitA의 energy가 2 감소 UnitA.decreseEnergy(); } }​ package day05; public class UnitA { String type; int energy; UnitA(String type){ this.type = type; energy = 10; } public void decreseEnergy(){ energy ..
package day05; public class SelectionSortEx { //배열 정렬하기 public static void main(String[] args) { int[] A = {8,5,6,3,7}; selectionSort(A); for(int i=0;i
package day04; public class Car { static int count; String prodNo; //p-1 private String color; //기본생성자 Car(){ count++; prodNo = "p-"+count; } //public Car(int count){ //this.count = count; //} // //public Car(String prodNo){ //this.prodNo = prodNo; //} // //public Car(String color){ //this.color = color; //} // public void setProdNo(String ProdNo){ this.prodNo = prodNo; } public void setColor(St..
package day04; public class Atest { public static void main(String[] args) { System.out.println(A.staticVariable); A a = new A(10); //기본생성자 호출, 객체 생성 a.staticVariable = -1; A aa = new A(100); aa.staticVariable = -999; A aaa = new A(1000); aaa.staticVariable = -20000; System.out.println("static-참조변수로 출력(a)" + a.staticVariable); System.out.println("static-참조변수로 출력(aa)" + aa.staticVariable); System..
송 이
'Language/java' 카테고리의 글 목록 (2 Page)