Basically i am looking to make things to read a text firl & create points based upon the data. However i get two errors when i compile it, kindly see the code bellow.
private static Point setPoints(String pathIn)
int a = 0;
int b = 5;
int size = -1;
int counter = 0;
String xHold = null;
String yHold = null;
int x = -1;
int y = -1;
BufferedReader in = new BufferedReader(new FileReader(pathIn));
while ((str = in.readLine()) != null)
if (size != -1)
xHold = str.substring(a, b);
str = str.replaceFirst(xHold + " ", "");
yHold = str;
while(xHold.indexOf(" ") != -1)
xHold = xHold.replaceFirst(" ", "");
x = Integer.parseInt(xHold);
while(yHold.indexOf(" ") != -1)
yHold = yHold.replaceFirst(" ", "");
y = Integer.parseInt(yHold);
size = Integer.parseInt(str);
points = new Pointsize;
if (x <= 32767 && x >= 0
&& y <= 32767 && y >= 0)
Point g = new Point(x,y);
pointscounter = g;
catch (IOException e)
----jGRASP exec: javac -g -Xlint:unchecked Fast.java
Fast.java:137: error: variable points might not have been initialized
pointscounter = g;
Fast.java:146: error: variable points might not have been initialized
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
basically after this i just come to know about the error, but nothing i have changed & fixed it..
looking for help...
Web Design Company
This topic has been locked.
1 reply Latest Post - 2012-11-10T02:40:37Z by SystemAdmin
Pinned topic java problem: problem in returning a variable
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2012-11-10T02:40:37Z at 2012-11-10T02:40:37Z by SystemAdmin
SystemAdmin 110000D4XK210 PostsACCEPTED ANSWER
Re: java problem: problem in returning a variable2012-11-10T02:40:37Z in response to michaeljordan846Firstly,your error is because of the initial problem, because you do not initial the reference points at the point you declare it,and put it in the try-catch statement,Point g = new Point(x,y);pointscounter = g; statements won't be executed,if there is some Exception occured before it.This will result in the situation that using a reference be initial it, to which is not allows.Solution:you could just change "Point points = null;".
Secondly,I think your program make a strict limitation on your format of you input file.If it is not for a special use, I think it may make your code weak!
Hope this can serve you some help.