Jump to content

8 posts in this topic

Recommended Posts

Posted (edited)

Basic Java Program (first program)

SCROLL DOWN TO BOTTOM FOR LINE BY LINE EXPLANATION

This tutorial is for people who have never programmed in their lives.

What you will need:

A Compiler (For fun programs I use Eclipse java IDE for Developers)

1) You will first need to create your project and a class (using the traditional camelCase)

2) Create the following methods:

methods.png

3) Compare your code to this: 

Program1.png

4) Experiment with the simple 

System.out.print("");

putting "println" instead of just "print" 

"ln" will compile and after the text is printed it will go to the next line.

5) Print "Hello World!"

To print text all you have to do is place text inside of the ""

for example:

helloworld.png

as you can see above when ran it my text inputted!

6) That's it for a cool example of one of my old projects experimenting with printing

copy and paste this code into your compiler!

FEEL FREE TO EDIT AND PLAY AROUND WITH THIS CODE*

 

https://raw.githubusercontent.com/TorinTurner/java/master/Corvette

 

*do not take credit for my code. Also, the program is an example of polymorphism and/or inheritance.

Line by Line Explanation:

public class helloWorldEXPLAINED { //public means that this class is accessable by other packages, private means it is NOT accessable by other packages

	public static void main(String[] args) { //public and static means that it can be changes throughout the class
		// TODO Auto-generated method stub
		System.out.println("Hello World"); //this is your basic. System accesses the system lol, out means output, and print means print to console or whatver you initailzed to
	}

}

-LifeElevated

Updated by Crypto
Changed first code text from html to Java
  • Like 2
  • Informative 1
Posted

Nice TuT :frantic: But since it's for complete beginners I suggest you explain the code more (I.E. Public vs Private classes. The fact it uses dot notation) Other than that it's pretty good (y)

Posted
1 minute ago, LifeElevated said:

Software Development and Android

Could you explain what each line does please? I might get into it.

Posted
1 minute ago, bR34Kr said:

Nice TuT :frantic: But since it's for complete beginners I suggest you explain the code more (I.E. Public vs Private classes. The fact it uses dot notation) Other than that it's pretty good (y)

Good thinking!

1 minute ago, Joka said:

Could you explain what each line does please? I might get into it.

yes!

×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines