Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how create java class

+9 votes
asked Sep 19, 2024 by ????? ?????? (210 points)

2 Answers

0 votes
answered Sep 26, 2024 by Peter Minarik (101,420 points)

Dog.java

public class Dog
{
    private String _name;
    
    public Dog(String name)
    {
        _name = name;
    }
    
    public String GetName() { return _name; }
}

Main.java

public class Main
{
    public static void main(String[] args)
    {
        Dog dog = new Dog("Butch");
        System.out.println("My Dog is called: " + dog.GetName());
    }
}

See this for more details: https://www.w3schools.com/java/java_classes.asp

0 votes
answered Oct 11, 2024 by Nikhila Nandyala (410 points)
public class My class{
        private String message;
        public My class(String message){
              this.message= message;
}

          public void display message(){
               System.out.println("Message:"+message);
}
          public static void main(string[] args){
              My class My object=new My class("Hello,World!");
               my object.displayMessage();
    }
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and receive answers from other members of the community.
...