1

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)).

1
  • These are two different ways to the same goal, I don't think this is a question, which belongs to this website. Commented Apr 7, 2018 at 22:18

2 Answers 2

1

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?

Sign up to request clarification or add additional context in comments.

1 Comment

They create classes like this (photo) but not with code like this (photo)
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.