- 2
while we create a new object v use () at the end of the class name y do v use that
7 Antworten
+ 2
my question ws when we create a new object the syantax is class_name obj_name= new class_name(); why do v use this ()
+ 2
to pass arguments to the objects constructor. If there is no arguments then they are left blank. Let's say your object has a constructor with parameters String, Int, and Double. When you create the object, you put Object lobster = new Object("String", 8, 12.3); They are placeholders for potential arguments
0
() is used to pass values to that objects constructor. If no values are being passed, the () are left empty.
0
your question isn't clear enough.we dont use () with classes , we use them in methods .
0
because class_name() is a constructor which is a method also . you can pass a prameter or not depending on the constructor which you can define it in its class or if you didnt the java will do that automatically
0
My question I to make apps by using c
- 1
enjoy v