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.

what to use about this im new in java languages

+4 votes
asked Aug 29, 2019 by anonymous
public class Data

{

public static void main (String [] args)

{

double size = 125.83d;

short grade = 87;

double final_grade = grade;

int final_lenght = size;

System.out.println("data is :" +sum);

}

}

1 Answer

0 votes
answered Jun 3, 2025 by Jerry Jeremiah (2,040 points)

This is used for a non-static class.
So first you need to create a class.
The main function is static so it doesn't do that automatically.
So create an object of Main type (or some other class from a file with the same name):

public class Main
{
    public static void main(String[] args) {
        System.out.println("Hello World 1");
        Main example = new Main("Hello World 2");
        example.println();
    }
    private String text;
    public Main(String text) {
        this.text = text; // copy the input argument to the class member
    }
    public void println() {
        System.out.println(this.text); // print the class member
    }
}

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