mar
Person.java
1 Answer(s)      6 years and 10 months ago
Posted in : Java Beginners

Ads

View Answers

October 12, 2009 at 1:00 PM


Hi Friend,

Try the following code:

import java.util.*;

public class Person
{
int matricNo;
String name;
String date;
String gender;
public Person(int matricNo,String name,String date,String gender){
this.matricNo=matricNo;
this.name=name;
this.date=date;
this.gender=gender;
}
public void setMatricNo(int matricNo){
matricNo=matricNo;
}
public int getMatricNo(){
return matricNo;
}

public void setString(String name){
name=name;
}
public String getName(){
return name;
}

public void setDate(String date){
date=date;
}
public String getDate(){
return date;
}

public void setGender(String gender){
gender=gender;
}
public String getGender(){
return gender;
}
public static void main(String args[]){
System.out.println("Enter Matric No");
Scanner input=new Scanner(System.in);
int no=input.nextInt();
System.out.println("Enter Name");
String n=input.next();
System.out.println("Enter Date of Birth in format MM-dd-yyyy");
String dob=input.next() ;
System.out.println("Enter Gender");
String g=input.next();
Person person=new Person(no,n,dob,g);
int mNo=person.getMatricNo();
String personName=person.getName();
String dateB=person.getDate();
String gen=person.getGender();
System.out.println(mNo+" "+personName+" "+dateB+" "+gen);
}
}

Thanks









Related Tutorials/Questions & Answers:
Person.java - Java Beginners
Person.java  Write a class called Person.java that has instance variables matric number, name, date of birth, and gender. Use appropriate data types for these instance variables. Include constructor and set and get methods
How to integrate core java with Hibernate
Hibernate Example. Index.jsp Web.xml HibernateUtil.java Person.java
Advertisements
servlet javabean - JSP-Servlet
servlet javabean  how to use a java bean in servelts .plese give me one example program using servelt mvc concept.  Hi Friend, Try the following code: 1)Person.java: public class Person { private String name
SPEL-Wiring Null
; } } Person.java: This class contains the name of the person. package
Wiring References To List Element
; } } Person.java: This class contains the name of the person. package
Hibernate saveOrUpdate Method
and then created a POJO / Persistent class named Person.java to fetch... : Person.java package roseindia.net; public class Person { private int id
Calling Methods Using SpEL
by calling methods. Person.java: The Person class contains property named "
Spring Validation
. Person.java package com.roseindia; public class Person { private
Use Java Bean In Servlets
. Here is the code of Person.java public class Person { private String name
JPA One-to-One Relationship
; Model Class: Person.java address.java...: Person.java /** *  */ package
Hibernate SessionFactory
inside the <property> sub tag of <session-factory> tag. Person.java
Dirty Checking In Hibernate
the Java Application Directory Structure Person.java package net.roseindia
Why this is not working...?
and Person.java files.   public class Person { private String name
Hibernate 4 Annotations Tutorial
: Here is the code of Entity class (Person.java): package net.roseindia
Hibernate 4 Annotation Example
Person.java using the Annotations (may be called Entity class). package
First Hibernate Application
-configuration> Step 6 : Created a POJO class (persistent class) named Person.java

Ads

Advertisement