Person.java

Ads

 
 
 

Share on Google+Share on Google+

mar
Person.java
1 Answer(s)      7 years 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

Ads









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
Tutorials   
Java Spring Hibernate Struts Training java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient How do I resolve this Java Class not found exception? httpclient java.lang.NoClassDefFoundError Apache Commons ioutils maven dependency Read/Convert an inputStream to a String What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile?

Ads

 
Advertisement null

Ads