Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how do i can solve for java object.....pls help..

Status
Not open for further replies.

wilfrid100

Newbie level 6
Joined
Nov 27, 2005
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,370
Code:
   public static Object[][] readTextFile()
    throws FileNotFoundException, IOException
    {
  try
  {
        BufferedReader in = new BufferedReader(
                new FileReader("C:/Documents and Settings/seng/Desktop/testfile/assignment_matrix.txt"));
        
        List list = new ArrayList();
        String text;
        while((text = in.readLine()) != null)
        {
            Object[] out = text.split(" "); // Separated by "whitespace"
            for (int index = 0; index< out.length; index++)
                out[index] = Integer.parseInt((String)out[index]);  //problem here
            list.add(out);
        }
        
        Object[][] output = (Object[][])list.toArray(new Object[0][0]);
        return output;
    }
    
            catch ( IOException exc )
             {
                exc.printStackTrace();
             }
      
		
        return new Object[0][0];
    }


does any1 can let me know how do i can solve for tis problem?
Code:
out[index] = Integer.parseInt((String)out[index]);
the complier say this is an
Code:
incompatible type, found: int, required: java.lang.Object
 

Integer.parseInt() returns int, which is a primary data type and cannot be casted to a reference data type. You can create an object of type Integer, which can be casted to Object. To do this, use the below statement
out[index] = new Integer(Integer.parseInt((String)out[index]));
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top