Skip to content

Commit fbe5011

Browse files
authored
Create Tostring.java
1 parent 7b86325 commit fbe5011

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Tostring.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class Tostring
2+
{
3+
int rollno;
4+
String name;
5+
String course;
6+
7+
Tostring(int rollno, String name, String course){
8+
this.rollno = rollno;
9+
this.name = name;
10+
this.course = course;
11+
}
12+
13+
public String toString() //overriding the toString() method
14+
{
15+
return rollno+" "+name+" "+course;
16+
}
17+
public static void main(String args[]){
18+
Tostring s1=new Tostring(1,"Juned","B.Tech");
19+
Tostring s2=new Tostring(2,"Javed","B.Tech");
20+
21+
System.out.println(s1);
22+
System.out.println(s2);
23+
}
24+
}

0 commit comments

Comments
 (0)