// Student is the classclassStudent{Stringname="Momo";}// Main class to test the Student classpublicclassMain{publicstaticvoidmain(String[]args){// s1 is the object of the Student classStudents1=newStudent();System.out.println(s1.name);}}
constructor in java
java code:
// Student classclassStudent{Stringname;// Instance variable// ConstructorpublicStudent(Stringfullname){this.name=fullname;}}// Main class to test the Student classpublicclassMain1{publicstaticvoidmain(String[]args){// Create an object of the Student classStudents1=newStudent("Momo");// Print the nameSystem.out.println(s1.name);}}
Stop building auth from scratch. Kinde handles authentication, user management, and billing so you can focus on what matters - shipping great products your users will love.
On job as freelancer working with Java, JDK17+, Jenkins, Maven, Docker, K3S, Git, In my spare time I'm trying to blog about something useful(?) or try to hack on things I like.
Stop building auth from scratch. Kinde handles authentication, user management, and billing so you can focus on what matters - shipping great products your users will love.
Dive into this insightful article, celebrated by the caring DEV Community. Programmers from all walks of life are invited to share and expand our collective wisdom.
A simple thank-you can make someone’s day—drop your kudos in the comments!
On DEV, spreading knowledge paves the way and strengthens our community ties. If this piece helped you, a brief note of appreciation to the author truly counts.
Top comments (2)
Why not using a record; is easier:
ok i'll remind it thank you so much for the suggestion