• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

syntax error

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi everyone
I got a syntax error:
any help is greatly apriciate

Code:
import java.util.*;
import java.io.*;

public class Person implements Serializable {
private String first_name = null;
private String middle_name = null;
private String last_name = null;
private Calendar birthday = null;
private String gender = null;

public static final String MALE = "Male";
public static final String FEMALE = "Female";

public Person(String f_name, String m_name, String l_name, int dob_year, int dob_month, int dob_day,String gender){

first_name = f_name;
middle_name = m_name;
last_name = l_name;
this.gender = gender;

birthday = Calendar.getInstance();
birthday.set(dob_year, dob_month, dob_day);
}

public int getAge(){
Calendar today = Calendar.getInstance();
int now = today.get(Calendar.YEAR);
int then = birthday.get(Calendar.YEAR);
return (now - then);
}

public String getFullName(){ return (first_name + " " + middle_name + " " + lastname);

public String getFirstName(){ return first_name;}
public void setFirstName{String f_name) ( first_name = f_name

public String getMiddleName(){ return middle_name;}
public void setMiddleName{String m_name) ( middle_name = m_name

public String getLastName(){ return last_name;}
public void setLastName{String l_name) ( last_name = l_name

public String getNameAndAge(){ return (getFullName() + " " + getAge());

public String getGender(){ return gender;}
public void setGender(String gender){ this.gender = gender; }

public void setBirthday(int year, int month, int day){ birthday.set(year, month, day);}

public String toString(){
return.this.getFullName() + " " + gender + " " + birthday.get(Calendar.DATE) + "/" + birthday.get(Calendar.MONTH) + "/" + birthday.get(Calendar.YEAR);
}

public boolen equals(Object o){
if(o == null) return false;
boolen is_equal = false;
if(o instanceof Person){
if(this.first_name.equals(((Person)o).first_name) &&
this.middle_name.equals(((Person)o).middle_name) && this.gender.equals(((Person)o).gender) &&
this.birthday.get(Calendar.YEAR) == ((Person)o).birthday.get(Calendar.YEAR)) &&
this.birthday.get(Calendar.MONTH) == ((Person)o).birthday.get(Calendar.MONTH)) &&
this.birthday.get(Calendar.DATE) == ((Person)o).birthday.get(Calendar.DATA)) ){
is_equal = true;
}
}
return is_equal;
}
} //end Person class

Errors:
34: illegal start of expression
public String getFirstName(){ return first_name;}
68: ";" expected
} //end Person class
 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


There is no closing brace at the end of this method.
 
Suela Smith
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Garrett
Now every thing works fine
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code compiles with winky faces in it?
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeff Albertson:
Your code compiles with winky faces in it?



Those winky faces are just ";)" characters. The original poster forgot to disable smilies in the post.

Henry
 
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic