String[] tempStrArry, tempStrArry2;
int[] playerOneBase = null, playerTwoBase = null;
When do I need to use the =null part? On the String arrays no problems occur but when I use the integer arrays netbeans wants me to initialise them as null.
I can post more of my code if need be but the arrays are used in similar ways so I don't think they have any impact.
Edit: The small part is where the errors start to occur but the large part is the whole code so far.
for (int j = 0; j < tempStrArry.length; j++) {
playerOneBase[j] = Integer.parseInt(tempStrArry[j]);
}
public class GameMain {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
// TODO code application logic here
// Variables
int tempInt, tempInt2;
String tempString, tempString2;
String[] tempStrArry, tempStrArry2;
int[] playerOneBase = null, playerTwoBase;
int[] playerOneCurrent = null, playerTwoCurrent;
String classStats = "RangeClasses.txt";
//Constructors
Scanner userInput = new Scanner(System.in);
try {
ReadFile classFile = new ReadFile(classStats);
String[] aryLines = classFile.OpenFile();
int i;
for (i = 0; i < aryLines.length; i++) {
System.out.println(aryLines[i]);
}
/*
Prompt user
Get Input
Input from string to int
increment integer (stat Line)
store stat line as string
split stat line into string array
*****make string array to int array
make base = current
*/
System.out.println("Player One Choose Class");
tempString = userInput.next();
tempInt = Integer.parseInt(tempString);
tempInt++;
tempString = aryLines[tempInt];
tempStrArry = tempString.split(",", 4);
for (int j = 0; j < tempStrArry.length; j++) {
playerOneBase[j] = Integer.parseInt(tempStrArry[j]);
}
playerOneCurrent = playerOneBase;
System.out.println("Player Two Choose Class");
tempString = userInput.next();
tempInt = Integer.parseInt(tempString);
tempInt++;
} catch (IOException e) {
System.out.println(e.getMessage());
}
while (playerOneCurrent[0] > 0) {
}
}
}