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)).
-
These are two different ways to the same goal, I don't think this is a question, which belongs to this website.Nikolaus– Nikolaus2018-04-07 22:18:43 +00:00Commented Apr 7, 2018 at 22:18
Add a comment
|
2 Answers
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