10) Constructors
Create a class with a parameterized constructor and display its value.
← All Topics
▶ Run Program
Java Code
class Student { String name; Student(String n) { name = n; } void show() { System.out.println("Student: " + name); } } public class Main { public static void main(String[] args) { Student s = new Student("Amit"); s.show(); } }
Program Input (optional)
Output