Click here to Skip to main content
14,241,236 members
   

Java

 
AnswerRe: Java SE 8 OCA Exam Pin
Richard MacCutchan9-Oct-18 5:29
protectorRichard MacCutchan9-Oct-18 5:29 
QuestionThreads Priority Pin
ashutoshgadgil8-Oct-18 22:46
memberashutoshgadgil8-Oct-18 22:46 
AnswerRe: Threads Priority Pin
Richard MacCutchan8-Oct-18 23:01
protectorRichard MacCutchan8-Oct-18 23:01 
GeneralRe: Threads Priority Pin
ashutoshgadgil9-Oct-18 6:45
memberashutoshgadgil9-Oct-18 6:45 
GeneralRe: Threads Priority Pin
Richard MacCutchan9-Oct-18 7:03
protectorRichard MacCutchan9-Oct-18 7:03 
QuestionProject execution Pin
Member 138896166-Oct-18 8:46
memberMember 138896166-Oct-18 8:46 
AnswerRe: Project execution Pin
OriginalGriff6-Oct-18 8:48
protectorOriginalGriff6-Oct-18 8:48 
QuestionDeclaring one variable as multiple things. How? Pin
Member 1397832611-Sep-18 21:02
memberMember 1397832611-Sep-18 21:02 
I was looking at the code for a tictactoe game the other day and saw something that confused me.

The X and O were called Pegs. They were not called X and O out right. They were just trying to put down code that simulated players taking turns placing a Peg. The game would switch between first player and second player turn:
private Peg currentPeg;
private Peg[][] cells = new Peg[SIZE][SIZE];

public Peg checkRowMatch() {
    for (int i = 0; i < SIZE; i++) {
        if(cells[i][0]== cells[i][1] && cells[i][1] == cells[i][2] && cells[i][0] != Peg.NONE){
            return cells[i][0];
        }
    }
    return Peg.NONE;
}

public Peg checkColumnMatch() {
    for (int j = 0; j < SIZE; j++) {
        if(cells[0][j]== cells[1][j] && cells[1][j] == cells[2][j] && cells[0][j] != Peg.NONE){
            return cells[0][j];
        }
    }
    return Peg.NONE;
}

public enum Peg {NONE, FIRST, SECOND};


As you can see, the variable Peg was used as a type declaring different things. It was used as an enum, an array, as methods. My question is how. There is no class Peg anywhere in the code so how is Peg being used as some king of data type?
AnswerRe: Declaring one variable as multiple things. How? Pin
Richard MacCutchan11-Sep-18 21:24
protectorRichard MacCutchan11-Sep-18 21:24 
QuestionHow to add a toolbar to JInternalFrame ? Pin
Withanam5-Sep-18 0:42
memberWithanam5-Sep-18 0:42 
AnswerRe: How to add a toolbar to JInternalFrame ? Pin
Richard MacCutchan5-Sep-18 0:50
protectorRichard MacCutchan5-Sep-18 0:50 
QuestionJavaFX DatePicker update value to null [SOLVED] Pin
Valentinor3-Sep-18 1:11
memberValentinor3-Sep-18 1:11 
AnswerRe: JavaFX DatePicker update value to null Pin
Valentinor29-Sep-18 6:53
memberValentinor29-Sep-18 6:53 
QuestionJava cv Pin
Member 1391875527-Aug-18 17:53
memberMember 1391875527-Aug-18 17:53 
AnswerRe: Java cv Pin
Richard MacCutchan27-Aug-18 22:01
protectorRichard MacCutchan27-Aug-18 22:01 
AnswerRe: Java cv Pin
GiteHrudaya25-Nov-18 22:15
memberGiteHrudaya25-Nov-18 22:15 
QuestionJavaFX program exit without Java JDK installed [SOLVED] Pin
Valentinor25-Aug-18 9:22
memberValentinor25-Aug-18 9:22 
QuestionRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 1:33
protectorRichard MacCutchan25-Aug-18 1:33 
AnswerRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 3:06
memberValentinor25-Aug-18 3:06 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 3:17
protectorRichard MacCutchan25-Aug-18 3:17 
AnswerRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 3:18
memberValentinor25-Aug-18 3:18 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 3:28
protectorRichard MacCutchan25-Aug-18 3:28 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 3:42
memberValentinor25-Aug-18 3:42 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 4:19
memberValentinor25-Aug-18 4:19 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 5:47
protectorRichard MacCutchan25-Aug-18 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.