private int [] minValues;
private int count = 0;


String[] tempString ;
tempString = line.split("-");
System.out.println(tempString[0]);

but when i try to add the store into array's code,

private int [] minValues;
String[] tempString ;
tempString = line.split("-");

minValues[count] = tempString[0]; <-- it say incompatible types

System.out.println(tempString[0]);

count++;

Recommended Answers

All 5 Replies

tempString[0] is a String, minValues[count] is an int. You can't assign an String to an int, they are "incompatible types". You can use something like Integer.parseInt to convert the String to an int, assuming that it contains a valid integer value and not just some random letters.

but when i change it to

String[] tempString ;
tempString = line.split("-");
minValues[count] = Integer.parseInt(tempString[0]);
System.out.println(tempString[0]);

it will appear this:


java.lang.NullPointerException
at Auction.propertyReadFromFile(Auction.java:75)
at Main.main(Main.java:9)
at __SHELL12.run(__SHELL12.java:6)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at bluej.runtime.ExecServer$3.run(ExecServer.java:724)

That's progress. You have fixed the compile error, now you are able to move on and find your run-time errors.
That message is telling you you have an un-initialised (null) variable on line 75 in the propertyReadFromFile method in the Auction class

but i dun have .. line 75?

java.lang.NullPointerException
at Auction.propertyReadFromFile(Auction.java:75)

You did when you compiled the code that this refers to!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.