- 2

while we create a new object v use () at the end of the class name y do v use that

28th Jul 2016, 1:47 PM
Nitin Varghese
Nitin Varghese - avatar
7 ответов
+ 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 ()
28th Jul 2016, 8:43 PM
Nitin Varghese
Nitin Varghese - avatar
+ 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
29th Jul 2016, 12:38 AM
James
James - avatar
0
() is used to pass values to that objects constructor. If no values are being passed, the () are left empty.
28th Jul 2016, 2:35 PM
James
James - avatar
0
your question isn't clear enough.we dont use () with classes , we use them in methods .
28th Jul 2016, 6:15 PM
Nermeen Ahmed
Nermeen Ahmed - avatar
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
29th Jul 2016, 12:27 AM
Nermeen Ahmed
Nermeen Ahmed - avatar
0
My question I to make apps by using c
29th Jul 2016, 6:10 PM
Tribhusan kharel
Tribhusan kharel - avatar
- 1
enjoy v
5th Aug 2016, 1:39 PM
Tammie Younger
Tammie Younger - avatar