When I call the constructor in the main program, the default values are getting displayed. I want the values initialized in the default Constructor()
When I call the constructor in the main program, the default values are getting displayed. I want the values initialized in the default Constructor(). Why constructor overloading is not happening when I explicitly define the default constructor. How do I call them in the main program?
Why java is not giving me default constructor
package com.vedantkakade; class Student { String fname; String lname; public void printInfo() { System.out.println(fname + ” ” + lname); } Student(Student other) { this.fname = other.fname; this.lname = other.lname; } } public class temp { public static void main(String[] args) { Student s1 = new Student(); //Error: constructor Student in class com.vedantkakade.Student cannot be applied […]
(JAVA)How to make a class constructor with an expansible atribute
I have to make a system for a restaurant for a university project, but don’t know how to make the class constructor for the “orders” class, i need a constructor that lets me add multiple meals from the menu, and only take the order ID and table after the user clicked on confirm for the meals.