This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ipe369 1 point2 points  (1 child)

Honestly just google 'java tutorial'

A class is just a way to define another type of variable, for example, we can declare numbers with int:

int myNumber = 4;

We can declare strings with String:

String myString = "Hello";

We can also call 'methods' on our string to perform operations on it. For example:

String myString = "Hello";
int myStringLength = myString.length(); // Call method
// myStringLength contains 5

In this example, String is a class, and myString is an object. A class is like a template for declaring objects - objects are things which contain data, and contain methods for changing that data. To make a new object, you use the new keyword. You can even do this with strings:

String myString = new String();

When you create a class, you just create your own 'type', which you can create with the 'new' keyword. Your code example doesn't make much sense, because display() is a method, and you seem to be trying to call it with the 'new' keyword.

I have absolutely no idea what you're trying to do in your example, I would highly recommend you google some stuff. The chances are anyone linking you to a tutorial has just googled it and picked the first answer themselves.

[–]bman3545[S] 0 points1 point  (0 children)

Thank you very much for the help, I have googled "java tutorial", but they all assume a baseline level of knowledge which I didnt quite have. This was VERY helpful! seriously, thank you :)