0

How do you create objects in BlueJ?

7th Apr 2017, 2:51 PM
amit
2 Answers
+ 8
For a reminder, object is an instance of a class: For Scanner: Scanner obj = new Scanner(System.in);
7th Apr 2017, 2:55 PM
Dev
Dev - avatar
0
Maybe a bit to late, but for all the others: You have your little Folder-Symbol, representing an class. Let's say it's called "Example". You can right-click it now, and chose 'new Example ()' Then pass the constructor the parameters and at the "Object bench" a representation of your object will appear. Another possibility: At the code-window at the bottom right(if you can't see it, go to preferences and activate it there) you can now either type in 'new Example ()' and it will give you an Object (I'm not sure about that though, sorry) or you type "Example ex = new Example ();" That has the same effect as doing it via the context menu of the class thing. There are quite a lot of other ways, but those are propably the easiest ones
19th Feb 2018, 4:24 PM
D B
D B - avatar