tostring() java example
public String toString()
{
return getClass().getName()+"@"+Integer.toHexString(hashCode());
}
// Java program to illustrate
// working of toString() method
class Best_Friend {
String name;
int age;
String college;
String course;
String address;
Best_Friend
(String name, int age, String college, String course, String address)
{
this.name = name;
this.age = age;
this.college = college;
this.course = course;
this.address = address;
}
public String toString()
{
return name + " " + age + " " + college + " " + course + " " + address;
}
public static void main(String[] args)
{
Best_Friend b =
new Best_Friend("Gulpreet Kaur", 21, "BIT MESRA", "M.TECH", "Kiriburu");
System.out.println(b);
System.out.println(b.toString());
}
}
Also in Java:
- java animated gif example
- inheritance setter and getter in java
- JavaFX onMouseEntered
- code to include layout from java in android
- faire un timer en java
- java square a number
- 3-way radix quicksort java
- adding an element to the end of a linked list java
- string to arraylist convert java
- java get folder content
- Kotlin is like java
- goodbye java
- java cast duration to long
- java convert string with commas to long
- what is a float java
- android java shared preferences remove key
- tolowercase java
- java read string input
- insertion sort doubly linked list java
- java switch display panel
- java list get first element
- Java.awt graphics tutorial
- how to make a pre set list java
- stack overflow recyclerview