I am working on may code and I received a null pointer error , how do I fix this? all I wanted to do was remove the selected array here's my code
import java.util.Scanner;
public class Game {
public static void main(String args[]){
Scanner input = new Scanner( System.in );
Briefcase briefcase[] = new Briefcase[11];
double amounts[] = {0,100,200,300,400,500,600,700,800,900,1000,25000};
for(int i = 0; i<11 ; i++){
briefcase[i] = new Briefcase();
double value = amounts[i];
briefcase[i].setAmount(value);
briefcase[i].setFace(i);
}
for(int a = 1 ;a<11; a++){
System.out.print("\t "+briefcase[a].getFace()+" ");
if(a%5==0){
System.out.println();
}
}
System.out.print("\tPlease Chose your Case! : ");
int nUser = input.nextInt();
int myCase = briefcase[nUser].getFace();
briefcase[nUser].getAmount();
briefcase[nUser] = null;
System.out.println("\tYou've chosen BriefCase number! "+myCase);
for(int z = 0 ; z<=11;z++)
{
if(briefcase[z] == null){
System.out.println("Blarg");
}
System.out.println(" "+briefcase[z].getFace());
}
}
}
and here is the other class
public class Briefcase {
double amount;
int face;
public void setAmount(double amount){
this.amount = amount;
}
public double getAmount(){
return this.amount;
}
public void setFace(int face){
this.face = face;
}
public int getFace(){
return face;
}
}