Reputation: 51
My question might not be useful but I really need to know why a lot of people creat new classes (Right-click, create new, class) but not use code to create a new class (for example: class task(var title:String, var time:String)
).
Upvotes: 1
Views: 363
Reputation: 328
lets says you very simple app with MainActivity.class you want to add a new class.
you can do it in a separate file (right-click, create a new class) or in the MainActivity.class declare the class, for example
public class Car {
private String carModel;
private String carColor;
//constructor
public Car (String carModel, String carColor) {
this.carColor = carColor;
this.carModel = carModel;
}
//add setters and getters, methods and other stuff
Upvotes: 0
Reputation: 390
I have never seen creating classes like that. Seems like you've mixed up functions with classes. Can you provide us any source where this way of creating classes is used?
Upvotes: 1