literature

My First Java Program

Deviation Actions

Precipitous120's avatar
Published:
567 Views

Literature Text

My First Java Program:

 

Welcome to your first java program, here we will explore where to download Netbeans (a programming platform) and make your very first java program.

 

 

Now you might be asking yourself, ‘But why should I learn programming, what could I do with it?’ well...With programming the possibilities are limitless, and for once that isn’t just an empty statement. If a genie granted you three wishes and one of your wishes was for endless power, don’t be too surprised if the magic lamp spits out a programming tutorial. Programming is magic and the more you learn from it the more you will realise just how powerful it has made you become MWAHAHAH! It is productive, it is quantitative, it is a source of ever growing skill at your fingertips. Now let us begin.


Programming is composed of three main parts.
components
classes

libraries
For this tutorial we will look at components. Components are the simplest to start with and libraries are the hardest :P. Classes contain components and Libraries contain classes. This means that while components are the simplest to understand, they are also the most important building block of programming :)

Within components you get variables. We will look a few variables in this tutorial. Here are some variables:

int, double, float...etc which hold numbers

Char, String. For characters and letters

Boolean. For true and false statements

Now lets get started ;) 

First of all go to this web site ___link___ and download both Netbeans and JDK. I provided another link above in the word Netbeans, just in case one of these two links does not work ;).  If you do not have Java you will have to download it as well, make sure to download the correct bit size for your computer(If your computer is 32 bit or 64bit, download the likewise bit model of Netbeans and JDK)

1 by Precipitous120
Next you are going to need to install Netbeans and JDK before you can start programming. Once inside Netbeans open a new project. To do this go to the tab on the top left hand corner of your screen and find the ‘Open’ tab. Follow down the new drop down list and find the tab that says ‘New Project’.

2 by Precipitous120
From there you should find a category list on the left of your screen and a projects list on the right. Select ‘Java’ on your left and under projects select ‘Java Application’. Click Next. 


Now give your project a name, I chose ‘MyFirstProgram’ as the name of my project. Click Finish


Now let us begin, as you can see in the image the below code for your first program will go between the Brackets{} of the main class. Write out the below code or copy and paste it inside netbeans, I would prefer that you write out the code word for word so that you better learn to remember code instead of copy and pasting it from the internet :D3 by Precipitous120


 

A few notes before you start coding, Slashes like these // mean that anything in the line to the right of these slashes are just a comment and not actually part of the code. That bit you do not need to write out.

 

Netbeans helps you code by giving all the different functions each class has, sometimes when you put a full stop down you will get a list of every possible class that can be used in your code. For now Ignore these options. This becomes very useful for when you need to learn new parts of a class you already understand.

 

Spaces do not matter in java, go ahead and try it out, even if there are large spaces between your code it will not result in a funny underlined red squiggle

 

The Code, write out the following:

 

public static void main(String[] args) {

 

System.out.println("Hello World\nToday I am going to write my first java program");//System.print prints out messages to the console screen, this is often used by programmers but never seen by the end user

 

char InitalSurname='M';//char stores single charcaters or numbers, it can not hold anything more than 1 letter or number

 

String Name="Your Name";//String is used to store any string of characters, meaning you could write sentences or even a single character and String would be used to capture these variables

 

int Age=0;//int holds integers, numbers in other words :) int can not hold fractions below zero or very long numbers but it can hold negative and positive values

   

System.out.println("My Name is "+Name+" I am "+Age+" years old and my surname starts with a "+InitalSurname);

 

System.out.println("This is my first java program and I found it fun and easy, soon I will take over the world MWAHAHAHAHA!");   

    }

 

With your code written out click run(the green triangle on the top of your screen) or hit f6 on your keyboard.
4 by Precipitous120


The end result is that your program should print out the following.

‘Hello World

Today I am going to write my first java program

My Name is Your Name I am 0 years old and my surname starts with a M

This is my first java program and I found it fun and easy, soon I will take over the world MWAHAHAHAHA!’

 

I hope you enjoyed this short tutorial and that you continue to program and learn more, but before you go let me tell you some of what can be accomplished with java alone.

 

 

EVIL!

 

Java can be used to Totally destroy someone’s computer by erasing their register files and even deleting their Operating system. The reason that Java can do this is because it has its own Virtual machine which runs every program you create with it. A virtual machine is basically like having a miniature computer inside your computer. Inside the VM the rules of your computer do not apply meaning every protection protocol of your computer can be broken in half and shredded to pieces. Allowing Java to decimate your computer without harming itself in the process. Using Java you can even cause a computer to self-destruct in a blaze of fire!

 

Good?

 

Java can be used to build tools which is super boring, but remember these tools are made to whatever specification you want! You can create a program to edit and make music, videos, art and games. You can mould your skills and knowledge into an educational tool to teach others or you can say bugger to the rest of you guys I want to get PAID! Make your own servers, create your own internet, develop your own chat service that only you and your friends can access. Rule the world from your own private club house. Go nuts because you can do anything with the right code. You can even create a homework machine that gives children more homework… I mean solves homework! MWAHAHA

 

Neutral…

 

Java can be used to data mine(collect data) the internet, encrypt files, copy files, read files, destroy them. Build universal translators. Develop Artificial intelligence. Solve incredible complex mathematics. Make technology more efficient. Make humans obsolete. Solve the coming Robots VS Humans war. With Java there is nothing that is impossible.  

A quick look at how to make your first program. We go over some of the main factors that make a code.

int(integers)
String(words or sentences)
char(single characters)

These are the building blocks of all coding because at some point in every code they are included. They are very basic representations of values used later, and as your knowledge on code expands you will slowly learn grander examples of values and how to use them

I hope this helps and feel free to ask any questions :D
Comments1
Join the community to add your comment. Already a deviant? Log In
Codepuppy's avatar
Cooool!   : D

do   < code>  tags work in DeviantArt?   : D

edit: HEYYY They do!!   : DD
That'll make it SO MUCH EASIER to put codes up in a proper monospace font like in Netbeans or Eclipse or etc.!  XD

So, for any coders reading this, when you would write

  public static void main(String[] args) {

  System.out.println("Hello World\nToday I am going to write my first java program");
  }

You can instead put it inside <code> tags and it'll look like this!   : DD

public static void main(String[] args) {
    System.out.println("Hello World\nToday I am going to write my first java program");
}