자바 이클립스 사용법 질문좀..
-
게시물 수정 , 삭제는 로그인 필요
c언어 할때는 비쥬얼스튜디오로 그냥 별 문제없이 쉽게쉽게 했는데요
이번에 자바를 공부하게 됐는데 자바는 이클립스를 쓰더라구요
c언어 할땐 친구꺼 복사 붙여넣기로 해도 컴파일 돼서 실행이 잘 됐는데
자바는 계속 오류나고 빨간밑줄 생기고 클래슨지 패키진지 그거 때문인거 같은데
import java.util.Random;
public class DiceTest {
public static void main(String[] args) {
Dice dice = new Dice();
for (int i = 0; i < 5; i++) {
dice.throwDice();
}
dice.printResult();
}
}
class Dice {
private Random random;
private Integer[] resultArray1;
private Integer[] resultArray2;
private int gameCount;
private int index;
public Dice() {
random = new Random();
resultArray1 = new Integer[5];
resultArray2 = new Integer[5];
}
public void printResult() {
int result = 0;
System.out.println("총 게임 횟수 : " + gameCount);
for (int a : resultArray1) {
result += a;
}
System.out.println("A 획득 점수 : " + result);
result = 0;
for (int a : resultArray2) {
result += a;
}
System.out.println("B 획득 점수 : " + result);
}
public void throwDice() {
gameCount++;
int diceNum = random.nextInt(6) + 1;
int diceNum2 = random.nextInt(6) + 1;
if (diceNum == diceNum2) {
throwDice();
} else if (diceNum > diceNum2){
resultArray1[index] = diceNum;
resultArray2[index] = 0;
index++;
} else if (diceNum < diceNum2) {
resultArray1[index] = 0;
resultArray2[index] = diceNum2;
index++;
}
}
}
이 프로그램을 실행시키고 싶은데 도대체 방법을 모르겠네요
패키지 파일 없이 클래스명과 파일명을 일치시키라는데 그것도 무슨말인지 모르겠네요;;
어떻게해야하죠?
c언어 할때는 비쥬얼스튜디오로 그냥 별 문제없이 쉽게쉽게 했는데요
이번에 자바를 공부하게 됐는데 자바는 이클립스를 쓰더라구요
c언어 할땐 친구꺼 복사 붙여넣기로 해도 컴파일 돼서 실행이 잘 됐는데
자바는 계속 오류나고 빨간밑줄 생기고 클래슨지 패키진지 그거 때문인거 같은데
import java.util.Random;
public class DiceTest {
public static void main(String[] args) {
Dice dice = new Dice();
for (int i = 0; i < 5; i++) {
dice.throwDice();
}
dice.printResult();
}
}
class Dice {
private Random random;
private Integer[] resultArray1;
private Integer[] resultArray2;
private int gameCount;
private int index;
public Dice() {
random = new Random();
resultArray1 = new Integer[5];
resultArray2 = new Integer[5];
}
public void printResult() {
int result = 0;
System.out.println("총 게임 횟수 : " + gameCount);
for (int a : resultArray1) {
result += a;
}
System.out.println("A 획득 점수 : " + result);
result = 0;
for (int a : resultArray2) {
result += a;
}
System.out.println("B 획득 점수 : " + result);
}
public void throwDice() {
gameCount++;
int diceNum = random.nextInt(6) + 1;
int diceNum2 = random.nextInt(6) + 1;
if (diceNum == diceNum2) {
throwDice();
} else if (diceNum > diceNum2){
resultArray1[index] = diceNum;
resultArray2[index] = 0;
index++;
} else if (diceNum < diceNum2) {
resultArray1[index] = 0;
resultArray2[index] = diceNum2;
index++;
}
}
}
이 프로그램을 실행시키고 싶은데 도대체 방법을 모르겠네요
패키지 파일 없이 클래스명과 파일명을 일치시키라는데 그것도 무슨말인지 모르겠네요;;
어떻게해야하죠?
#자바 이클립스 #자바 이클립스 설치 #자바 이클립스 다운로드 #자바 이클립스 사용법 #자바 이클립스 단축키 #자바 이클립스 글자 크기 #자바 이클립스 vscode #자바 이클립스 다크모드 #자바 이클립스 왼쪽 창 #자바 이클립스 인텔리제이