0% found this document useful (0 votes)
19 views

java student constructor

Uploaded by

fojimaw327
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

java student constructor

Uploaded by

fojimaw327
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.util.

Scanner;
public class student
{
int sroll;
String sname;
String saddress;
String smail;

public student(int sroll,String sname, String saddress, String smail)


{
this.sroll=sroll;
this.sname=sname;
this.saddress=saddress;
this.smail=smail;
}

void display()
{
System.out.println("The student details are ");
System.out.println("The student roll no is "+sroll);
System.out.println("The student name is "+sname);
System.out.println("The student address is "+saddress);
System.out.println("The student mail id is "+smail);
}

public static void main(String args[])


{
System.out.println("Enter the student details");
student s1=new student(1,"a","chennai","[email protected]");

student s2=new student(2,"b","Madurai","[email protected]");

student s3=new student(3,"c","Trichy","[email protected]");

s1.display();
s2.display();
s3.display();
}
}

You might also like