HI everyone!I am a beginner in java and i need your help,please if u can help me
i have write this code :

package person;

public class person {
	private String Name;
	private String Birthday;
	public person (String name,String birthday)
	{
		super ();
		Name=name;
		Birthday=birthday;
	
	}
	public String getName()
	{
		return Name;
		
	}
public void setName(String name)
{
	Name=name;
  

}
public String getBirthday()
{
	return Birthday;
}
public void setBirthday(String birthday)
{
	Birthday=birthday;
}
}

i have write this code and i want a program that implement a class Person,and the data of the class person are name and birthday and then i ought to use get and set methot for consult and change the information of person...i have write this cod in java but when i compile it i dont take any result..can enyone can tell me what i ought to do??please
best regards dhija 22

Well first of all you need a main method...then you should instantiate an object of type Person in the main method...then sent it two arguments (name,birthday).

public class person {
private String Name;
private String Birthday;

public static void main(String[] args)
{
person ob = new person("Bill","21st October");
system.out.prinln(ob.getName);

system.out.prinln(ob.getBirthday);

ob.setBirthday = "30th January"; //change values

ob.setName = "James";//change values

system.out.println(ob.getName);

system.out.println(ob.getBirthday);


}


public person (String name,String birthday)
{
Name=name;
Birthday=birthday;

}
public String getName()
{
return Name;

}
public void setName(String name)
{
Name=name;


}
public String getBirthday()
{
return Birthday;
}
public void setBirthday(String birthday)
{
Birthday=birthday;
}
}

when i compile it i dont take any result.

That is good. The compiler doesn't print out any messages if it did not find any errors.
What happens when you try to execute the program?

ok thanx james6754,its ok....
but i hav an other problem if i want a list of preson not only one two or three...awant to have a list with more preson that i want to consult their name and birthday and change their data please,can u help me with told what i ought to do?please!
NormR1 and me the compilator dont give any errors..but dont give nothing :O but i waited something like the program that james6754 give me..
thank you a lot for every thing
Regards dhija22

the compilator dont give any errors..but dont give nothing

The compiler should give you either some error messages or a .class file.
One or the other.

normR1 do u execute the program that james6754 geve me? its ok now

I was waiting for you to post your code.

> if i want a list of preson not only one two or three..

Use an ArrayList unless your assignment requires you to use a simple array of Person[].

Member Avatar for hfx642

I've cleaned this up a bit for you.

package person; 

public class person 
{
   private String Name;
   private String Birthday;	
   
   public person (String name, String birthday)	
   {
      Name = name;
      Birthday = birthday;
   }
   
   public String getName () { return Name; }
   public String getBirthday () { return Birthday; }
   
}

This is what is know as a "record" class.
It is used to create/access binary "record"s (sequentially) of type (in this case) person!
You don't need; super, main method, or any set methods!!!
I use this for ALL of my data files.

I've cleaned this up a bit for you.

You forgot to change the code to conform to coding standards. For example: The case of class names and variable names are reversed.

> or any set methods!!!

Well, I would imagine that the assignment calls for setters as well since it is an "into to objects" type of assignment.

Additionally, the class name should be capitalized and the instance variable names should start with lowercase letters by convention.

Edit: hehe, cross-posted with Norm. I'm not the only standards stickler :)

I guess that since there are no other specific questions, this thread is solved.

Member Avatar for hfx642

I've been programming for 30 years.
I DO follow standards... Unfortunately, they are MY standards.

Unfortunately when you post your code in public, you are not teaching the OPs the standards the majority of us use.

Member Avatar for hfx642

I re-read what I had written.
Actually, I didn't use MY standards. // Sorry
I used the code that the OP posted and took out all of the stuff the OP didn't need.

But still, you would have complained about MY standards, because I like to Capitalize All of MY Data_Items and GUI_Items, and use Under_Scores insteadOfCrammingWordsTogether.
lol!!

Let's try to set a good example for OPs by using the current coding standards.

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.