Click here to Skip to main content
14,661,643 members
Home » Discussions » Java
   

Java

 
AnswerRe: Finalize method in java Pin
ashutoshgadgil16-Oct-18 22:29
Memberashutoshgadgil16-Oct-18 22:29 
GeneralRe: Finalize method in java Pin
Richard MacCutchan16-Oct-18 23:07
mveRichard MacCutchan16-Oct-18 23:07 
GeneralRe: Finalize method in java Pin
ashutoshgadgil16-Oct-18 23:11
Memberashutoshgadgil16-Oct-18 23:11 
QuestionInspecting java application (Java spy, Java object inspector) - Automation Pin
Member 1383827315-Oct-18 18:58
MemberMember 1383827315-Oct-18 18:58 
RantJava, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
nated09913-Oct-18 18:41
Membernated09913-Oct-18 18:41 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
Richard MacCutchan14-Oct-18 1:35
mveRichard MacCutchan14-Oct-18 1:35 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
#realJSOP5-Nov-18 4:27
mva#realJSOP5-Nov-18 4:27 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
nated09927-Dec-18 8:27
Membernated09927-Dec-18 8:27 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
Mycroft Holmes14-Oct-18 13:12
professionalMycroft Holmes14-Oct-18 13:12 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
Eddy Vluggen15-Oct-18 0:53
professionalEddy Vluggen15-Oct-18 0:53 
GeneralRe: Java, Eclipse, Windowbuilder regarding a homemade Desktop App Pin
#realJSOP5-Nov-18 4:33
mva#realJSOP5-Nov-18 4:33 
QuestionDaemon Thread Pin
ashutoshgadgil11-Oct-18 21:50
Memberashutoshgadgil11-Oct-18 21:50 
AnswerRe: Daemon Thread Pin
Richard MacCutchan11-Oct-18 22:34
mveRichard MacCutchan11-Oct-18 22:34 
QuestionJava SE 8 OCA Exam Pin
Willem Voigt9-Oct-18 1:34
MemberWillem Voigt9-Oct-18 1:34 
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
Memberashutoshgadgil8-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
Memberashutoshgadgil9-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
MemberMember 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
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
mveRichard 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
mveRichard MacCutchan5-Sep-18 0:50 

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.