To DaveyB re: variable data might not have been initialised

I tried to reply to your thread but got a server error. It's not happening for other threads, and I don't know if others are experiencing the same problem.
If you don't get a response within the next hour, try posting again, or just reply here.
In the meantime, your problem is this:
int[] x;
x[0] = 1; // ERROR
int[] y = new int[10];
y[0] = 1;You didn't give the array variable x a value.

I am very sorry and thank you very much for anwering...
I was waiting for an email to drop into my inbox stating my my message had an answer, strange that you can't reply to my thread.
Here is the modified version
                    Object [][] data = {{this.now(), "test", "test"}};
                    while(s.getResultSet().next()) {
                            data[0] = s.getResultSet().getDate(2);
data[i][1] = s.getResultSet().getString(1);
data[i][2] = s.getResultSet().getString(7);
System.out.println(i++);
final JTable table = new JTable(data, columnNames);
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
When this is ran I get the below error, I specified this before but didn't give an example.  I hope the example helps.run:
0
ERROR java.lang.ArrayIndexOutOfBoundsException: 1
Java2D Direct3D usage disabled by J2D_D3D env
BUILD SUCCESSFUL (total time: 59 seconds)

Similar Messages

  • Variable data might  not have been initialised &

    Object [][] data; //WARNING variable data is not used
                        while(s.getResultSet().next()) {
                                data[0] = s.getResultSet().getDate(2); // ERROR variable data might not have been initialised
    data[i][1] = s.getResultSet().getString(1);
    data[i][2] = s.getResultSet().getString(7);
    System.out.println(i++);
    final JTable table = new JTable(data, columnNames); // ERROR variable data might not have been initialised
    Hi All,
    I am trying to load some items from my database server into my Object array and then pass the Object array into my JTable to be displayed.  The problem is when I put the data[0]... within my while loop I get compilation errors starting that the variable might not have been inititialised.
    So I then intialise my array but when I do that I get this Error: ERROR java.lang.ArrayIndexOutOfBoundsException: 1.
    Any ideas how I can get it to load my data properly?

    Note: please post responses to either of #1 or #2, attempting to reply to the OP will fail with a server error.
    db
    Edited by: DarrylBurke
    Question already answered in [http://forums.sun.com/thread.jspa?threadID=5412500]

  • Variable might not have been initialised?

    Hi I declare 2 lists at the begining of a method, the is "wrapped" using the Collections.synchronizedList method but when I try to compile the application it gives me the errors variable alltitles might not have been initialised and variable allauthors might not have been initialised: Here is my code
    List allauthors = Collections.synchronizedList(new ArrayList(allauthors));
          List alltitles = Collections.synchronizedList(new ArrayList(alltitles));//The next statements are inside a loop
    alltitles.add(TITLE);
                allauthors.add(names);I cannot figure out how to initialise the list at the begining of the method?
    is this the problem please help

    I'll give you a hint on how to default-initialize any object so that the compiler stops bothering you :
    x = null;hope this helps ;-)

  • Variable j might not have been initialized

    import java.io.*;
    import java.util.*;
    class Multiply
    public static void main(String args[]) throws IOException
    int i=1,j;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("enter a number:");
    int n = Integer.parseInt(br.readLine());
    if(j==i*n && i<=20)
    System.out.println(" the multiply table is:" +j);
    i++;
    i ompile this program but this gives an error i.e.,
    variable j might not have been initialized
    if(j==i*n && i<=20)
    what's my mistake i couldn't understand
    pls help me

    > what's my mistake i couldn't understand
    You initialized 'i', but not 'j'. You try to access 'j' before it has been initialized. The compiler is telling you that such a thing is against the rules.
    ~

  • Variable strShow might not have been initialized

    <%
    String strShow,strFigure;
    for (int i=0;i<100;i++)
         strFigure=Integer.toString(i); // does it really not be initialized ?
    strShow+=strFigure; // strShow can't automatically wisely assign memory space for itself ?
    %>
    the errors messages:
    variable strShow might not have been initialized
    strShow+=strFigure;
    variable strFigure might not have been initialized
    strShow+=strFigure;

    the codes should be remedied like this :
    <%
    String strShow=new String();
    String strFigure=new String();
    for (int i=0;i<100;i++)
         strFigure=Integer.toString(i);
    strShow+=strFigure;
    out.println(strShow);
    %>
    now I have a further comprehension about String object,thanks!

  • Variable mois might not have been initialized error help

    String mois;
              switch (month)
                   case 1:
                   mois = "January";
                   break;
                   case 2:
                   mois = "February";
                   break;
    System.out.println (mois);
    after compiling im getting this error.....variable mois might not have been initialized.....I don't know what it is....can somebody help???

    int month = keyboard.nextInt ();
              if (month >= 1 && month <= 12)
              else
                   System.out.println ("Error: invalid month. Must be in the range [1,12]");
    String mois;
              switch (month)
                   case 1:
                   mois = "January";
                   break;
                   case 2:
                   mois = "February";
                   break;
                   case 3:
                   mois = "March";
                   break;
                   case 4:
                   mois = "April";
                   break;
                   case 5:
                   mois = "May";
                   break;
                   case 6:
                   mois = "June";
                   break;
                   case 7:
                   mois = "July";
                   break;
                   case 8:
                   mois = "August";
                   break;
                   case 9:
                   mois = "September";
                   break;
                   case 10:
                   mois = "October";
                   break;
                   case 11:
                   mois = "November";
                   break;
                   case 12:
                   mois = "December";
                   break;
    System.out.println (mois);
    what is wrong with this then??? im getting the initialized error with the output of mois........

  • Variable myConnection might not have been initialized

    I'm getting a strange exception I don't understand. Can anyone help me out?
    "variable myConnection might not have been initialized"
              DataSource dataSource;
              Connection myConnection;
              ResultSet rs;
              Statement pStmt;
         try {
              dataSource = getDataSource(request);;
              myConnection = dataSource.getConnection();
                                    // does stuff with connection
         } catch (SQLException sqle) {
              getServlet().log("Connection.process", sqle);
         } finally {
              try {
                   myConnection.close();
              } catch (SQLException e) {
                   getServlet().log("Connection.close", e);
         }

    Is there any way to force compliation of my code with
    this error?What??? An error is an error is an error. Just simply assign it to null beforehand, like you should do.

  • Variable cumulativeWrite might not have been initialized

    This one has stumped me.
    Ive already looked on Google before anyone says, i didnt find an understandable answer.
        public static void writeFile(){
            int writeInt;
            String writeStr;
            String cumulativeWrite;
            try {
                String path = "c:" + File.separator + "documents and settings" + File.separator + "antony" + File.separator + "desktop" + File.separator + "storage.txt";
                BufferedWriter out = new BufferedWriter(new FileWriter(path));
                for (int row = 0; row < 9; row++){
                    for (int col = 0; col < 9; col++){
                        writeInt = (data[row][col]);
                        writeStr = Integer.toString(writeInt);
                        cumulativeWrite = (cumulativeWrite + writeStr); //<----------ERROR HERE
                        System.out.println(cumulativeWrite);
                out.write(cumulativeWrite); //<----------ERROR HERE
                out.close();
            } catch (IOException e) {
            return;
        }Does anyone know why?
    Ant...

    It worked!
    Hmmmm, that's gay! That should have worked the way i
    had it!No it should not have. Are you calling the compiler a liar?
    For the first error, for instance, the compiler does not know what (cumulativeWrite + writeStr) evaluates to when cumulativeWrite was not given an initial value. What do you expect the intial value of (in a method, in the context of a local variable):
    String cumulativeWrite;
    to be? null? an empty string? "Forty-two"?

  • Variable reportCount might not have been initalized?

    import java.util.Scanner;
    import java.util.Random;
    public class Guessing
        public static void main (String[] args)
            final int max=10;
            int answer,guess,reportCount;
            Scanner scan = new Scanner (System.in);
            Random generator = new Random();
            answer = generator.nextInt(max) + 1;
            System.out.println ("I'm thinking of a number between 1 and "+max+".");
            System.out.print ("Guess what it is: ");
            guess = scan.nextInt();
            {while(true){
                System.out.print ("Sorry wrong answer please guess again: ");
                guess = scan.nextInt();
            if (guess==answer){
                    System.out.println("You got it! Good Guessing!"); 
                     break;
            else
            System.out.print ("");}
             for (guess=1;guess<=500;guess++)
                reportCount=reportCount+guess;
                System.out.println(reportCount);
    }

    What is reportCount supposed to represent?
    You might find it a good idea to format your code nicely: A maximum of one { per line, and have the closing } line up with the start of the line that contains its matching {.  Use braces for all if and for statements - even if they only have a single line.
    At the moment your code looks like this:{ /* -- why is this brace here? -- */
        while(true) {
            // code that keeps prompting until
            // the user guesses the correct number.
            // However long that takes.
        for(guess = 1; guess <= 500; guess++) {
            // these numbers are all added to reportCount
            // ie countCount is increased by 125,250
            /* -- why? -- */
        System.out.println(reportCount);
    }Edited by: pbrockway2 on Nov 29, 2007 6:13 PM

  • Variable theContract might not have been initialized

    import java.text.*;
    import java.util.Date;
    import javax.swing.*;
    import java.lang.*;
    class Employer {
         private String name = "";
         public Employer(String na) {
              name=na;
         public Employer() {
              this("");
         public void setName(String na) {
              name=na;
         public String getName() {
              return name;
    class Maid {
         private String name = "";
         public Maid(String na) {
              name=na;
         public Maid() {
              this("");
         public void setName(String na) {
              name=na;
         public String getName() {
              return name;
    class MaidAgency {
         private String registrationNo = "";
         public MaidAgency(String no) {
              registrationNo=no;
         public MaidAgency() {
              this("");
         public void setRegistration(String reg) {
              registrationNo=reg;
         public String getRegistration() {
              return registrationNo;
    abstract class Contract {
         private String contractID = "";
         private String contractDate ="";
         private Employer employer;
         private Maid maid ;
         private MaidAgency agency;
         public Contract(String id, String date, Employer em , Maid ma, MaidAgency m) {
              contractID=id;
              contractDate=date;
              employer=em;
              maid=ma;
              agency=m;
         public Contract() {
              this("","",null,null,null);
         public void setEmployer(Employer em) {
              employer=em;
         public Employer getEmployer() {
              return employer;
         public void setMaid(Maid ma) {
              maid=ma;
         public Maid getMaid() {
              return maid;
         public void setAgency(MaidAgency m) {
              agency=m;
         public MaidAgency getAgency() {
              return agency;
         public void setID(String id) {
              contractID=id;
         public String getID() {
              return contractID;
         public void setDate(String date) {
              contractDate=date;
         public String getDate() {
              return contractDate;
         public abstract double commission();
    class NewMaid extends Contract {
         private double airFare = 0;
         public NewMaid(String id, String date, Employer em , Maid ma, MaidAgency m, double fare) {
              super(id, date, em, ma, m);
              airFare=fare;
         public NewMaid() {
              this("","",null,null,null,0);
         public void setFare(double fare) {
              airFare=fare;
         public double getFare() {
              return airFare;
         public double commission() {
              return 900;
    class TransferMaid extends Contract {
         private double commissionRate = 0;
         public TransferMaid(String id, String date, Employer em , Maid ma, MaidAgency m, double comm) {
              super(id, date, em, ma, m);
              commissionRate=comm;
         public TransferMaid() {
              this("","",null,null,null,0);
         public void setCommission(double comm) {
              commissionRate=comm;
         public double getCommission() {
              return commissionRate;
         public double commission() {
              return 350;
    public class Try {
         public static void main(String[] args) {
              String theEmployerName;
              String theMaidName;
              String theRegistrationNo;
              String theContractID;
              String theContractDate;
              String contractType;
              double theCommisionRate;
              double theAirFare;
              Employer theEmployer = new Employer();
              Maid theMaid = new Maid();
              MaidAgency theAgency=new MaidAgency();
              Contract theContract;
              theEmployerName=Console.readString("Employer Name : ");
              theEmployer.setName(theEmployerName);
              theMaidName=Console.readString("Maid Name : ");
              theMaid.setName(theMaidName);
              theRegistrationNo=Console.readString("Registration No. : ");
              theAgency.setRegistration(theRegistrationNo);
              theContractID=Console.readString("Contract ID :");
              theContractDate=Console.readString("Contract Date :");
              contractType= Console.readString("Contract Type (<N>ew Maid / <T>ransfer Maid) : ");
              while (!contractType.equals("N") && !contractType.equals("T")) {
                   JOptionPane.showMessageDialog(null,"Wrong Contract Type!");
                   contractType= Console.readString("Contract Type (<N>ew Maid / <T>ransfer Maid) : ");
              if (contractType.equals("N")) {
                   theAirFare=Console.readDouble("Air Fare : ");
                   theContract=new NewMaid(theContractID,theContractDate,theEmployer,theMaid,theAgency,theAirFare);
              else {
                   if (contractType.equals("T")) {
                        theCommisionRate=Console.readDouble("Commission Rate : ");
                        theContract=new TransferMaid(theContractID,theContractDate,theEmployer,theMaid,theAgency,theCommisionRate);
              System.out.println("Contract ID = " + theContract.getID());  // error
    }I think theContract has been initialized after i choose N or T, but it's not???
    aww..my head's spinning.
    help!

    By the way, my name is Monica. Ron is my last
    name. No problem, though--it's a common mistake
    here. :)That reminds me about a funny thing. I was driving from Miami to Canada a couple of years ago, and each night I had to try to find a hotel and check in. Most people didn't know how to write my last name so I usually just gave them my (Swedish) drivers license so that they would be able to fill out the forms. I usually didn't read what they wrote when I checked in, but used to take a look at the papers when I checked out. One of the hotels had checked me in as:
    First name: K�rkort
    Last name: Sverige
    which means:
    First name: Drivers license
    Last name: Sweden
    Kaj Bjurman

  • Thread programming -  variable might not have been initialized

    Hi there,
    Probably a fairly simple one here (quite new to java), i'm trying to do some thread programming but I get this error.
    ThreadController.java:42: variable dataGeneratorThread might not have been initialized
    dataGeneratorThread.activeCount();
    The bit I dont understand is that I run
    this line here
    for(int i=0; i < JuliaFrame.NO_OF_DATA_GENERATORS; i++){
    dataGenerators[i] = new DataGenerator(JuliaFrame.ImageWidth,JuliaFrame.ImageHeight,inputBuffer);
    dataGeneratorThread = new WorkerThread(dataGenerators,juliaCalc,displayBuffer);
    dataGeneratorThread.start();
    but when I do
    dataGeneratorThread.activeCount()
    is balks.
    I check that the thread is alive first but dont no how to tell the compiler this - obviously NO_OF_DATA_GENERATORS could be 0 in which case the compiler would have issues - I just wish it was more trusting ;)
    Here is some of the code
    runable class{
    new Thread( new ThreadController(inputBuffer,displayBuffer,juliaCalc) ).start();
    public class ThreadController implements Runnable {
    DataBuffer inputBuffer;
    DataBuffer displayBuffer;
    JuliaCalc juliaCalc;
    /** Creates a new instance of ThreadController */
    public ThreadController(DataBuffer inputBuffer,DataBuffer displayBuffer,JuliaCalc juliaCalc) {
    inputBuffer = inputBuffer;
    displayBuffer = displayBuffer;
    juliaCalc = juliaCalc;
    public void run()
    DataGenerator[] dataGenerators = new DataGenerator[JuliaFrame.NO_OF_DATA_GENERATORS];
         WorkerThread dataGeneratorThread;
         for(int i=0; i < JuliaFrame.NO_OF_DATA_GENERATORS; i++){
    dataGenerators[i] = new DataGenerator(JuliaFrame.ImageWidth,JuliaFrame.ImageHeight,inputBuffer);
    dataGeneratorThread = new WorkerThread(dataGenerators[i],juliaCalc,displayBuffer);
    dataGeneratorThread.start();
    dataGeneratorThread.activeCount();
    int nNanoSecsBeforeCheck = 50;
    while(true)
    if(dataGeneratorThread.isAlive()){
    if(dataGeneratorThread.activeCount() > inputBuffer.size())
    public class DataGenerator implements Runnable {
    int nImageWidth;
    int nImageHeight;
    DataBuffer inputBuffer;
    public DataGenerator(int ImageWidth, int ImageHeight,DataBuffer inputBuffer) {
    nImageWidth = ImageWidth;
    nImageHeight = ImageHeight;
    public void run()
    // Non terminating thread - created datapakets and place them in the input buffer
    // Get two radom number withoin a bound and find out bout default highest colou - 3rd value
    while(true)
    int nRandomXCord;
    int nRandomYCord;
    nRandomXCord = ((int)(Math.random() * nImageWidth));
    nRandomYCord = ((int)(Math.random() * nImageHeight));
    DataPacket dpDataPacket = new DataPacket(nRandomXCord, nRandomYCord, 233);
    inputBuffer.put(dpDataPacket);

    Sorry about that, didnt realise.
    Hi there,
    Probably a fairly simple one here (quite new to java), i'm trying to do some thread programming but I get this error.
    ThreadController.java:42: variable dataGeneratorThread might not have been initialized
    The bit I dont understand is that I run
    this line here
    this line here
    for(int i=0; i < JuliaFrame.NO_OF_DATA_GENERATORS; i++){
    dataGenerators = new DataGenerator(JuliaFrame.ImageWidth,JuliaFrame.ImageHeight,inputBuffer);
    dataGeneratorThread = new WorkerThread(dataGenerators,juliaCalc,displayBuffer);
    dataGeneratorThread.start();
    }but when I do
    dataGeneratorThread.activeCount() is balks.
    I check that the thread is alive first but dont no how to tell the compiler this - obviously NO_OF_DATA_GENERATORS could be 0 in which case the compiler would have issues - I just wish it was more trusting ;)
    Here is some of the code
    runable class{
    new Thread( new ThreadController(inputBuffer,displayBuffer,juliaCalc) ).start();
    public class ThreadController implements Runnable {
    DataBuffer inputBuffer;
    DataBuffer displayBuffer;
    JuliaCalc juliaCalc;
    /** Creates a new instance of ThreadController */
    public ThreadController(DataBuffer inputBuffer,DataBuffer displayBuffer,JuliaCalc juliaCalc) {
    inputBuffer = inputBuffer;
    displayBuffer = displayBuffer;
    juliaCalc = juliaCalc;
    public void run()
    DataGenerator[] dataGenerators = new DataGenerator[JuliaFrame.NO_OF_DATA_GENERATORS];
    WorkerThread dataGeneratorThread;
    for(int i=0; i < JuliaFrame.NO_OF_DATA_GENERATORS; i++){
    dataGenerators = new DataGenerator(JuliaFrame.ImageWidth,JuliaFrame.ImageHeight,inputBuffer);
    dataGeneratorThread = new WorkerThread(dataGenerators,juliaCalc,displayBuffer);
    dataGeneratorThread.start();
    dataGeneratorThread.activeCount();
    int nNanoSecsBeforeCheck = 50;
    while(true)
    if(dataGeneratorThread.isAlive()){
    if(dataGeneratorThread.activeCount() > inputBuffer.size())
    public class DataGenerator implements Runnable {
    int nImageWidth;
    int nImageHeight;
    DataBuffer inputBuffer;
    public DataGenerator(int ImageWidth, int ImageHeight,DataBuffer inputBuffer) {
    nImageWidth = ImageWidth;
    nImageHeight = ImageHeight;
    public void run()
    // Non terminating thread - created datapakets and place them in the input buffer
    // Get two radom number withoin a bound and find out bout default highest colou - 3rd value
    while(true)
    int nRandomXCord;
    int nRandomYCord;
    nRandomXCord = ((int)(Math.random() * nImageWidth));
    nRandomYCord = ((int)(Math.random() * nImageHeight));
    DataPacket dpDataPacket = new DataPacket(nRandomXCord, nRandomYCord, 233);
    inputBuffer.put(dpDataPacket);
    }

  • Might not have been initialized

    I've seen this posted in here before and i've gone through a search but still can't figure out what i've done wrong.
    Here are the error's:
    A:\Chapter04\Tuition.java:101: variable tuition might not have been initialized
              total = tuition + fees;
    ^
    A:\Chapter04\Tuition.java:101: variable fees might not have been initialized
              total = tuition + fees;
    ^
    2 errors
    Tool completed with exit code 1
    Here is the code:
    public static void displayTotal(double total)
              double tuition, fees;
              total =  tuition +  fees;
              DecimalFormat twoDigits = new DecimalFormat("$#000.00");
              System.out.println("Your cost for tuition is; " + twoDigits.format(total));
    when I change ' double tuition, fees' to ' double tution = 0, fees =0; '
    it compiles fine but when run it does not return the right values, i'm sure its something silly like the last.
    Thanks again for your wisdom and patience                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    when I change ' double tuition, fees' to ' double
    tution = 0, fees =0; '
    it compiles fine but when run it does not return the
    right values, i'm sure its something silly like the
    last.So you set the tuition and fees to zero, added them to
    the value passed in, and expected to come up with
    something other than the original value? You need to
    get the right values for tuition and fees somehow. I
    have no idea how since I don't know anything about
    your application.I'm srry here is all the code:
    import java.io.*;
    import java.text.DecimalFormat;
    public class Tuition
         public static void main(String[] args) throws IOException
              //Declare variables
              int hours;
              double fees , rate, tuition;
              //Call methods
              displayWelcome();
              hours = getHours();
              rate = getRate(hours);
              tuition = calcTuition(hours, rate);
              fees = calcFees(tuition);
              displayTotal(tuition + fees);
         public static void displayWelcome()
              System.out.println("Welcome to the Tuition Calculator");
              System.out.println();
         public static int getHours() throws IOException
              //Declare variables
              BufferedReader dataIn = new BufferedReader ( new InputStreamReader(System.in));
              String strHours;
              int hours;
              hours = 0;
              // Get value from user
              System.out.println("Enter the total amount of Credit hours to be taken:");
                   strHours = dataIn.readLine();
                   try
                        hours = Integer.parseInt(strHours);
                   catch(NumberFormatException errNum)
                        System.out.println("Your entry was not in the proper format." + errNum.getMessage());//message prints with Java-generated data
              //Return a value to main
              return hours;
         public static double getRate(int hours)
              //Declare variables
              double rate;
              boolean done = false;
              if (hours > 15)
                   rate = (44.50);
              else
                   rate = (50.00);
         //Return a value to main
         return rate;
         public static double calcTuition(int hours, double rate)
              //Declare variables
              double tuition;
              tuition=0;
              tuition = hours * rate;
         //Return a value to main
         return tuition;
         public static double calcFees(double tuition)
              //Declare variables
              double fees;
               fees = tuition*.08;
         // Return a value to main     
         return fees;
         public static void displayTotal(double total)
              total =  (double)tuition +  (double)fees;
              DecimalFormat twoDigits = new DecimalFormat("$#000.00");
              System.out.println("Your cost for tuition is; " + twoDigits.format(total));

  • Pls Help! InetAddress: might not have been initialized

    variable inetAddr might not have been initialized
    InetAddress inetAddr = inetAddr.getByName(someClass.sInetAddr);
    where someClass.sInetAddr.equals("xxx . xxx . xxx . xxx")
    Please if you know help me.
    Thank you in advance

    Look at the other thread, you are trying to use the which you have yet to set variable instead of the class name to invoke getByName(). It should be:
    InetAddress inetAddr = InetAddress.getByName(someClass.sInetAddr);
    Chuck

  • Variable might not have been initialized, but I can't get around it...

    I'm getting a variable might not have been initialized error, and I know why, but I can't get around it. Basically, this snippet of my code is reading in a map file for a game. The first two lines of the map file are configuration information, and the rest is coordinates for the tiling graphics.
    while ((str = in.readLine()) != null) {
                    if(!read_info){
                        //process first line: tileset image, size, playerpos
                        temp = str.split(",");
                        loadTileset(temp[0],32);
                        size_x = Integer.parseInt(temp[1]);
                        size_y = Integer.parseInt(temp[2]);
                        map = new Tile[size_x][size_y];
                        player.resetLoc(Integer.parseInt(temp[3]),Integer.parseInt(temp[4]));
                        //process second line: impassible
                        str = in.readLine();
                        temp = str.split("!");
                        impassable = new Point[temp.length];
                        for(int m=0;m<temp.length;m++){
                            tmp_coords = temp[m].split(",");
                            impassable[m] = new Point(Integer.parseInt(tmp_coords[0]),Integer.parseInt(tmp_coords[1]));
                        read_info = true;
                    } else{
                        temp = str.split("!");
                        for(int i=0;i<size_x;i++){
                            tmp_coords = temp.split(",");
    boolean ti = true;
    for(int p=0;p<impassable.length;p++){
    map[i][j] = new Tile(Integer.parseInt(tmp_coords[0]),Integer.parseInt(tmp_coords[1]),true);
    j++;
    I'm not including everything.. this should make sense. Impassable is a Point[].
    I can't say how big the Impassable list will be until it reads the second line of the map file. However, that happens in the first run-through of the file-reading processes.
    Is there a try/catch statement I can use to get past this?

    If you set that variable to null you will fix this
    error.
    Object obj;to
    Object obj = null;Beware this may cuase NullPointerExceptions, so you
    should check this variable for being null before you
    try to access it.That's usually the wrong way to approach this. Getting this compiler error is often a sign of a logic error. Only initialize the variable if it makes sense for the variable to have that value. Don't do it just to satisfy the compiler.

  • Code problem, variable might not have been initialized..

    I have a program I'm working on, I have to seperate file classes.. I have one that is mainly just the class and its functions, the other I'm triing to get to use the previously mentioned class, but it keeps telling me that my variable might not have been initialized.. I have default constructor built in the first class file, but it doesn't seem to be using it when I try accessing it through the other class...
    Here is the code I just pasted it, so it kinda wrapped in some spots.
    class:
    public class Cat{
         private String color;
         private char gender;
         private boolean neutered;
         private String name;
         private int weight;
         public Cat(){
              color = "orange";
              gender = 'M';
              neutered = true;
              name = "Garfield";
              weight = 20;
         public void setColor(String catColor){
              color = catColor;
    public void setGender(char catGender){
              if ((catGender == 'f') || (catGender == 'F'))
              gender = 'F';
              else
         gender = 'M';
         public void setNeutered(char catNeutered){
         if ((catNeutered == 'Y') || (catNeutered == 'y'))
              neutered = true;
         else
                   neutered = false;
         public void setName(String catName){
              name = catName;
         public void setWeight(int catWeight){
              weight = catWeight;
         public void weigh(){
              System.out.println(name + " weighs " +
    weight + "lbs.");
         public void showColor(){
              System.out.println(name + " is " + color);
         public void eat(){
              System.out.println(name + " has eaten his food
    and is now full");
         public void yowl(){
              System.out.println(name + "yoowwwwllllll");
         public void fertility(){
              if (gender == 'F')
              if (neutered)
              System.out.println(name + "cannot have kittens.");
              else
                   System.out.println(name + "can have kittens.");
              else
         if (neutered)
         System.out.println(name + "cannot father kittens.");
    else
              System.out.println(name + "can father kittens.");
    This is what I'm triing to use it with:
    public class JailCats{
         public static void main (String[] args) {
              Cat meow1;
              meow1.weigh();
    }

    It is using the default c'tor. But since you didn't implement it, all it does is nothing.
    But that's not the (immediate) problem. Somewhere you're using a local variable without setting a value for it. Hint: look at the line the error message hints at. Because I can't, because you don't tell and your posted code is unreadable.
    Edit: yeah, here it is:
    Cat meow1;
    meow1.weigh();So where do you actually set the meow1 reference to point to a Cat instance?

Maybe you are looking for

  • Multi-mapping 1:n - 1:1

    Hi, We are using multi-mapping in a file-to-file interface. When we have 1:n everything is ok, but when we have 1:1 we have this error: Success The message status set to DLNG. Error Unable to find channel ID Error Delivery of the message to the appli

  • Hp recovery new hdd

    I have a HP Rossignol dv6 3260es that came with its' original HDD. I recently bought a new SSD hard drive with 250GB and replaced the old HDD with this new one. I kept the old HDD and placed it in the CD/DVD slot. Now I have 2 hard drives and no CD/D

  • Restrict schema size

    Hi everyone, Just wondering if there is a way in HANA to restrict the size (memory allowance) of a particular schema? We have some users that can create objects but want to be able to set a limit on the size of the tables they can create. Regards, Ma

  • TS1702 I upgrade and the passbook feature is not working ? How to get it to work

    How to make password work. Upgrade and it is not working when I try to open the passbook states that can not open App Store

  • Quiero Poder Saber Si Puedo Camviar Mi ipod Por Otro ipod Y Cuanto Custa

    Mi Ipod Lo Compre En Enero 2011 Mexico Blanco 32Gb El ipod Esta En Bunas Condiciones Pero Ya No Quiere Presionar El Botton Y DE Del Dock Ningun USB Aggara Ni En EL Esterio Ni Ningun Cargador Ayudenmen Costo Casi 5,000$ Quiero Aver Si Melo Pueden Arre