Share on Google+Share on Google+

1 Answer(s)      7 years ago
Posted in : Java Beginners
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){
public void setMatricNo(int matricNo){
public int getMatricNo(){
return matricNo;

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

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

public void setGender(String gender){
public String getGender(){
return gender;
public static void main(String args[]){
System.out.println("Enter Matric No");
Scanner input=new Scanner(;
int no=input.nextInt();
System.out.println("Enter Name");
System.out.println("Enter Date of Birth in format MM-dd-yyyy");
String ;
System.out.println("Enter Gender");
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);



Related Tutorials/Questions & Answers: - Java Beginners  Write a class called 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
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) public class Person { private String name
SPEL-Wiring Null
; } } This class contains the name of the person. package
Wiring References To List Element
; } } This class contains the name of the person. package
Hibernate saveOrUpdate Method
and then created a POJO / Persistent class named to fetch... : package; public class Person { private int id
Calling Methods Using SpEL
by calling methods. The Person class contains property named "
Spring Validation
. package com.roseindia; public class Person { private
Use Java Bean In Servlets
. Here is the code of public class Person { private String name
JPA One-to-One Relationship
; Model Class: /** *  */ package
Hibernate SessionFactory
inside the <property> sub tag of <session-factory> tag.
Dirty Checking In Hibernate
the Java Application Directory Structure package net.roseindia
Why this is not working...?
and files.   public class Person { private String name
Hibernate 4 Annotations Tutorial
: Here is the code of Entity class ( package net.roseindia
Hibernate 4 Annotation Example using the Annotations (may be called Entity class). package
First Hibernate Application
-configuration> Step 6 : Created a POJO class (persistent class) named
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?


Advertisement null