14,241,236 members

# Java

 Re: Java SE 8 OCA Exam Richard MacCutchan9-Oct-18 5:29 Richard MacCutchan 9-Oct-18 5:29
 Re: Threads Priority Richard MacCutchan8-Oct-18 23:01 Richard MacCutchan 8-Oct-18 23:01
 Re: Threads Priority Richard MacCutchan9-Oct-18 7:03 Richard MacCutchan 9-Oct-18 7:03
 Project execution Member 138896166-Oct-18 8:46 Member 13889616 6-Oct-18 8:46
 Re: Project execution OriginalGriff6-Oct-18 8:48 OriginalGriff 6-Oct-18 8:48
 Declaring one variable as multiple things. How? Member 1397832611-Sep-18 21:02 Member 13978326 11-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?
 Re: Declaring one variable as multiple things. How? Richard MacCutchan11-Sep-18 21:24 Richard MacCutchan 11-Sep-18 21:24
 How to add a toolbar to JInternalFrame ? Withanam5-Sep-18 0:42 Withanam 5-Sep-18 0:42
 Re: How to add a toolbar to JInternalFrame ? Richard MacCutchan5-Sep-18 0:50 Richard MacCutchan 5-Sep-18 0:50
 JavaFX DatePicker update value to null [SOLVED] Valentinor3-Sep-18 1:11 Valentinor 3-Sep-18 1:11
 Re: JavaFX DatePicker update value to null Valentinor29-Sep-18 6:53 Valentinor 29-Sep-18 6:53
 Java cv Member 1391875527-Aug-18 17:53 Member 13918755 27-Aug-18 17:53
 Re: Java cv Richard MacCutchan27-Aug-18 22:01 Richard MacCutchan 27-Aug-18 22:01
 Re: Java cv GiteHrudaya25-Nov-18 22:15 GiteHrudaya 25-Nov-18 22:15
 JavaFX program exit without Java JDK installed [SOLVED] Valentinor25-Aug-18 9:22 Valentinor 25-Aug-18 9:22
 Re: JavaFX program exit without Java JDK installed Richard MacCutchan25-Aug-18 1:33 Richard MacCutchan 25-Aug-18 1:33
 Re: JavaFX program exit without Java JDK installed Valentinor25-Aug-18 3:06 Valentinor 25-Aug-18 3:06
 Re: JavaFX program exit without Java JDK installed Richard MacCutchan25-Aug-18 3:17 Richard MacCutchan 25-Aug-18 3:17
 Re: JavaFX program exit without Java JDK installed Valentinor25-Aug-18 3:18 Valentinor 25-Aug-18 3:18
 Re: JavaFX program exit without Java JDK installed Richard MacCutchan25-Aug-18 3:28 Richard MacCutchan 25-Aug-18 3:28
 Re: JavaFX program exit without Java JDK installed Valentinor25-Aug-18 3:42 Valentinor 25-Aug-18 3:42
 Re: JavaFX program exit without Java JDK installed Valentinor25-Aug-18 4:19 Valentinor 25-Aug-18 4:19
 Re: JavaFX program exit without Java JDK installed Richard MacCutchan25-Aug-18 5:47 Richard MacCutchan 25-Aug-18 5:47
 Last Visit: 20-Jul-19 12:02     Last Update: 20-Jul-19 12:02 Refresh « Prev1...78910111213141516 Next »