Click here to Skip to main content
15,887,434 members
Home / Discussions / Java
   

Java

 
AnswerRe: Java SE 8 OCA Exam Pin
Richard MacCutchan9-Oct-18 5:29
mveRichard MacCutchan9-Oct-18 5:29 
QuestionThreads Priority Pin
ashutoshgadgil8-Oct-18 22:46
ashutoshgadgil8-Oct-18 22:46 
AnswerRe: Threads Priority Pin
Richard MacCutchan8-Oct-18 23:01
mveRichard MacCutchan8-Oct-18 23:01 
GeneralRe: Threads Priority Pin
ashutoshgadgil9-Oct-18 6:45
ashutoshgadgil9-Oct-18 6:45 
GeneralRe: Threads Priority Pin
Richard MacCutchan9-Oct-18 7:03
mveRichard MacCutchan9-Oct-18 7:03 
QuestionProject execution Pin
Member 138896166-Oct-18 8:46
Member 138896166-Oct-18 8:46 
AnswerRe: Project execution Pin
OriginalGriff6-Oct-18 8:48
mveOriginalGriff6-Oct-18 8:48 
QuestionDeclaring one variable as multiple things. How? Pin
Member 1397832611-Sep-18 21:02
Member 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
mveRichard MacCutchan11-Sep-18 21:24 
QuestionHow to add a toolbar to JInternalFrame ? Pin
Withanam5-Sep-18 0:42
Withanam5-Sep-18 0:42 
AnswerRe: How to add a toolbar to JInternalFrame ? Pin
Richard MacCutchan5-Sep-18 0:50
mveRichard MacCutchan5-Sep-18 0:50 
QuestionJavaFX DatePicker update value to null [SOLVED] Pin
Valentinor3-Sep-18 1:11
Valentinor3-Sep-18 1:11 
AnswerRe: JavaFX DatePicker update value to null Pin
Valentinor29-Sep-18 6:53
Valentinor29-Sep-18 6:53 
QuestionJava cv Pin
Member 1391875527-Aug-18 17:53
Member 1391875527-Aug-18 17:53 
AnswerRe: Java cv Pin
Richard MacCutchan27-Aug-18 22:01
mveRichard MacCutchan27-Aug-18 22:01 
AnswerRe: Java cv Pin
GiteHrudaya25-Nov-18 22:15
GiteHrudaya25-Nov-18 22:15 
QuestionJavaFX program exit without Java JDK installed [SOLVED] Pin
Valentinor25-Aug-18 9:22
Valentinor25-Aug-18 9:22 
QuestionRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 1:33
mveRichard MacCutchan25-Aug-18 1:33 
AnswerRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 3:06
Valentinor25-Aug-18 3:06 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 3:17
mveRichard MacCutchan25-Aug-18 3:17 
AnswerRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 3:18
Valentinor25-Aug-18 3:18 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 3:28
mveRichard MacCutchan25-Aug-18 3:28 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 3:42
Valentinor25-Aug-18 3:42 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Valentinor25-Aug-18 4:19
Valentinor25-Aug-18 4:19 
GeneralRe: JavaFX program exit without Java JDK installed Pin
Richard MacCutchan25-Aug-18 5:47
mveRichard 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.