- Joined
- Jul 2, 2019
- Posts
- 823
- Solutions
- 1
- Reaction
- 1,216
- Points
- 449
Attachments
-
You do not have permission to view the full content of this post. Log in or register now.
class Student{
String name;
// Overloading of constructor
public Student(){
this.name="Unknown";
}
public Student(String sName){
this.name=sName;
}
public static void main(String[]args){
Student s1=new Student();
Student s2=new Student("Aaron");
System.out.println(" Name of Student s1:\n");
System.out.println(" Name of Student s2:\n");
}
}
ito parin error hahaJava:class Student{ String name; // Overloading of constructor public Student(){ this.name="Unknown"; } public Student(String sName){ this.name=sName; } public static void main(String[]args){ Student s1=new Student(); Student s2=new Student("Aaron"); System.out.println(" Name of Student s1:\n"); System.out.println(" Name of Student s2:\n"); } }
Try mo TS not sure kung working pero wala nang error
class Main {
public static void main(String[] args){
Student s1 = new Student("Aaron");
System.out.println("\nName of Student s1: " + s1.name);
}
}
public class Student {
String name;
public Student(String sName){
this.name = sName;
}
}
class Student {
String name;
public Student(String sName){
this.name = sName;
}
}
class Main {
public static void main(String[] args){
Student s1 = new Student("Aaron");
System.out.println("\nName of Student s1: " + s1.name);
}
}
nice ty paps heheMain.java
Java:class Main { public static void main(String[] args){ Student s1 = new Student("Aaron"); System.out.println("\nName of Student s1: " + s1.name); } }
Student.java
Java:public class Student { String name; public Student(String sName){ this.name = sName; } }
OUTPUT:
Name of Student s1: Aaron
Or just inside the Main.java
Java:class Student { String name; public Student(String sName){ this.name = sName; } } class Main { public static void main(String[] args){ Student s1 = new Student("Aaron"); System.out.println("\nName of Student s1: " + s1.name); } }
nice ty paps hehe
oks na oks na papshehe ty poWelcome. Ok naba? Good luck lang sa mga exam.
Nakita mo sir yung mali sa code mo kaya di makita yung main class?oks na oks na papshehe ty po