help this pliz!
I am running this code, I gat about 8 errors,
public class IdentifyMyParts {
public static int x = 7;
public int y = 3;
IdentifyMyParts a = new IdentifyMyParts();
IdentifyMyParts b = new IdentifyMyParts();
a.y = 5;
b.y = 6;
IdentifyMyParts.x = 1;
b.x = 2;
System.out.println("a.y = " + a.y);
System.out.println("b.y = " + b.y);
System.out.println("a.x = " + a.x);
System.out.println("b.x = " + b.x);
}
This is the errors am getting could anyone help me to sort out this, Thx in advance
ntifyMyParts.java:7: <identifier> expected
= 5;
^
ntifyMyParts.java:8: <identifier> expected
= 6;
^
ntifyMyParts.java:9: <identifier> expected
ntifyMyParts.x = 1;
^
ntifyMyParts.java:10: <identifier> expected
= 2;
^
ntifyMyParts.java:11: <identifier> expected
tem.out.println("a.y = " + a.y);
^
ntifyMyParts.java:12: <identifier> expected
tem.out.println("b.y = " + b.y);
[1101 byte] By [
Elijah73a] at [2007-10-3 2:41:39]

you've got code statements in a class declaration - code statements need to go in a method e.g.
public class IdentifyMyParts {
public static int x = 7;
public int y = 3;
public static void main(String[]args) {
IdentifyMyParts a = new IdentifyMyParts();
IdentifyMyParts b = new IdentifyMyParts();
a.y = 5;
b.y = 6;
IdentifyMyParts.x = 1;
b.x = 2;
System.out.println("a.y = " + a.y);
System.out.println("b.y = " + b.y);
System.out.println("a.x = " + a.x);
System.out.println("b.x = " + b.x);
}
}
asjfa at 2007-7-14 19:40:19 >

Hi
I am trying to write a method given a String array comprising each line of a file, when run I want to create, fill and return an array of valid user object, am new in java I've write code am getting an error msg
this is the code I developed:
public class MethodName
{
public static String[] getFileName (String[] linesfile)
{
String[] users = new String[3];
users[0]=linesfile[0];
users[1]=linesfile[1];
users[2]=linesfile[2];
return users;
}
public static void main(String[] args)
{
System.out.println("valid users at index 0:"+ users[0]);
System.out.println("valid users at index 1:"+ users[1]);
System.out.println("valid users at index 2:"+ users[2]);
}
}
am getting 3 errors "can not find symbol
symbol: variable users
> Hi
> I am trying to write a method given a String array
> comprising each line of a file, when run I want to
> create, fill and return an array of valid user
> object, am new in java I've write code am getting an
> error msg
> this is the code I developed:
>
Java has a concept of variable scope. Basically, a variable's scope is within the { and its matching } where the variable is declared. In your code, you define the variable users inside a method. This variable does not exist outside the method.
In addition, your code never calls the getFileName method. It's difficult for me to give you advice because it isn't clear to me what you are trying to accomplish.