Hi
i´m a newbie at java-programming and im not an english spoken man but i´ll try to make you understand my problem. When i´m trying to pass an array to a method, the compailer says it cant resolve symbol. I´ve read my java-book and it isn´t helping.....
This is the code:
//MedelAlder.java
import java.util.*;
public class MedelAlder
{
public static void main ( String args [] )
{
final int NUMBER_OF_STUDENTS = 2;
Person n[] = new Person [NUMBER_OF_STUDENTS + 1];
for ( int i = 1; i <= NUMBER_OF_STUDENTS; i++)
{
ConsoleInput cin = new ConsoleInput ();
System.out.println("\nType your first name, last name and personal number:"
System.out.println("(Delimit your input with ','(e.g FirstName,lastName,birthDate)) "
String s1 = cin.readString ();
StringTokenizer st = new StringTokenizer(s1, ","
String firstName = st.nextToken();
String lastName = st.nextToken();
String birthDate = st.nextToken();
Person a = new Person();
a.setFirstName(firstName);
a.setLastName(lastName);
a.setBirthDate(birthDate);
n = a ;
}
if ( notEqualBirthDates )
{
System.out.println ("\n*****************************************\n"+
"FirstName" + "\t" + "LastName" + " \t" + "BirthDate\n"+
"---------" + "\t" + "--------" + " \t" + "---------\n"
for ( int i = 1; i <= NUMBER_OF_STUDENTS; i++ )
{
System.out.println ("\n" + i + "" + " " + n + "" );
}
}
else
{
System.out.println("That can not be true, check your birthdates"
}
}
}
----------------------------------------------------------
//Person.java
public class Person
{
private String firstName;
private String lastName;
private String birthDate;
public Person ()
{
}
public Person ( String fName, String lName, String bDate )
{
firstName = fName;
lastName = lName;
birthDate = bDate;
}
public void setFirstName ( String firstName )
{
this.firstName = firstName;
}
public String getFirstName ()
{
return firstName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getLastName ()
{
return lastName;
}
public void setBirthDate ( String birthDate )
{
this.birthDate = birthDate;
}
public String getBirthDate ()
{
return birthDate;
}
public static boolean notEqualBirthDates ( Person p[] )
{
boolean x = true;
//Stegar index på strängen
for ( int i = 1 ; i < p.length - 1 ; i++ )
{
//Stegar tecken från 1 till 9 och jämför med index
for (int j = i + 1 ; j < p.length ; j++ )
{
if ( p.getBirthDate() == p[j].getBirthDate() )
{
x = false;
return x;
}
}
}
return x;
}
public String toString ()
{
return ( firstName + "\t " + lastName + "\t\t" + birthDate + "." );
}
}
-----------------------------------------------------------
the compiler says:
MedelAlder.java:37: cannot resolve symbol
symbol : method notEqualBirthDates (Person[])
location: class MedelAlder
if ( notEqualBirthDates )
^
1 error
Tool completed with exit code 1
---------------------------------------------------------
Hope that someone out there can help me.
i´m a newbie at java-programming and im not an english spoken man but i´ll try to make you understand my problem. When i´m trying to pass an array to a method, the compailer says it cant resolve symbol. I´ve read my java-book and it isn´t helping.....
This is the code:
//MedelAlder.java
import java.util.*;
public class MedelAlder
{
public static void main ( String args [] )
{
final int NUMBER_OF_STUDENTS = 2;
Person n[] = new Person [NUMBER_OF_STUDENTS + 1];
for ( int i = 1; i <= NUMBER_OF_STUDENTS; i++)
{
ConsoleInput cin = new ConsoleInput ();
System.out.println("\nType your first name, last name and personal number:"
System.out.println("(Delimit your input with ','(e.g FirstName,lastName,birthDate)) "
String s1 = cin.readString ();
StringTokenizer st = new StringTokenizer(s1, ","
String firstName = st.nextToken();
String lastName = st.nextToken();
String birthDate = st.nextToken();
Person a = new Person();
a.setFirstName(firstName);
a.setLastName(lastName);
a.setBirthDate(birthDate);
n = a ;
}
if ( notEqualBirthDates )
{
System.out.println ("\n*****************************************\n"+
"FirstName" + "\t" + "LastName" + " \t" + "BirthDate\n"+
"---------" + "\t" + "--------" + " \t" + "---------\n"
for ( int i = 1; i <= NUMBER_OF_STUDENTS; i++ )
{
System.out.println ("\n" + i + "" + " " + n + "" );
}
}
else
{
System.out.println("That can not be true, check your birthdates"
}
}
}
----------------------------------------------------------
//Person.java
public class Person
{
private String firstName;
private String lastName;
private String birthDate;
public Person ()
{
}
public Person ( String fName, String lName, String bDate )
{
firstName = fName;
lastName = lName;
birthDate = bDate;
}
public void setFirstName ( String firstName )
{
this.firstName = firstName;
}
public String getFirstName ()
{
return firstName;
}
public void setLastName(String lastName)
{
this.lastName = lastName;
}
public String getLastName ()
{
return lastName;
}
public void setBirthDate ( String birthDate )
{
this.birthDate = birthDate;
}
public String getBirthDate ()
{
return birthDate;
}
public static boolean notEqualBirthDates ( Person p[] )
{
boolean x = true;
//Stegar index på strängen
for ( int i = 1 ; i < p.length - 1 ; i++ )
{
//Stegar tecken från 1 till 9 och jämför med index
for (int j = i + 1 ; j < p.length ; j++ )
{
if ( p.getBirthDate() == p[j].getBirthDate() )
{
x = false;
return x;
}
}
}
return x;
}
public String toString ()
{
return ( firstName + "\t " + lastName + "\t\t" + birthDate + "." );
}
}
-----------------------------------------------------------
the compiler says:
MedelAlder.java:37: cannot resolve symbol
symbol : method notEqualBirthDates (Person[])
location: class MedelAlder
if ( notEqualBirthDates )
^
1 error
Tool completed with exit code 1
---------------------------------------------------------
Hope that someone out there can help me.