Showing posts with label Programming Java Tutorials. Show all posts
Showing posts with label Programming Java Tutorials. Show all posts

Friday, January 27, 2012

The Way of the Programmer: A Warning. Also, numbers

Happy Pirate Hat Friday, everyone:

The Way of the Programmer can be dangerous for those who are impatient. A program doesn't program itself; you have to program EVERYTHING in the program. You need to be extremely patient with your program. Multiple versions must be made for even a simple little thing. However, once you finish your program, it would be like you slew a giant octopus with a toothbrush, like me.
I'm serious, you can't think it will be easy. That is not the way of the programmer! Stop doing it! If you think it will be easy, you will easily fall to the long process of programming. Just saying.

Now, today's lesson will be on integers.Yeah, that's right. Numbers.

Integers: A WHOLE new experience
Alright, integers are whole numbers. No decimals, no fractions, just positive and negative whole numbers. Now, you can make a decimal like an integer, but we will get into that. Now, integers only goes through the interval of (-2 billion, 2 billion), just about. Generally, this will be what you need for the job.

How do I declare an Integer?
Code that like this will get the job done:D
int myInt;
For initializing, do this
myInt = 42;
No quotation marks or anything, unless you are setting it to another variable.

Double: Double the fun, twice the work
A double is like an integer, but it includes a decimal, fraction, and other fun stuff

A prime example of a double is money. You can have 35 dollars, yes, but it's better to have 73.35 dollars. Doubles go farther in bounds than integers.

How do I declare a double? I don't understand! I'm literally tearing my hair out! Now I'm bald! What is going on???
Hahaha, silly new programmer. The way you declare a double is like an integer.
double myDouble;
Initializing just has a similar way, as well.
myDouble = 42.424242
Next time, we will talk more specifically on math.

-The Rich Man known as Thursday (Who isn't really rich, but pretends to be)

Wednesday, January 4, 2012

Programming (in Java): Eclipse, you, and your very own "Hello World" project.

Mwah hahahahahahaha!
Happy Evil Laugh Wednesday, everyone:

In this post, I am going to talk about some of the basics of programming. We will begin with Java, and, if we are lucky, we may continue on to C# and other languages. 

First thing, make sure you have something to code with. I prefer Eclipse(No, not twilight), created by Oracle. There is also Netbeans, which can help with further GUI things. However, we will be doing the majority of our work here, in Eclipse. Here is the link to the Eclipse download list, as well as part of the Oracle website: http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/index.html. Also, make sure you have Java downloaded on your computer. If you do not, the download should be on the same website.

Next, extract the files, it will be good for you. Once everything is set up, open Eclipse, and it will probably ask you for a location to put all your things. I prefer to put it in a default location, but you can put it anywhere you want. 
Now, we are going to get into the classic, simple program of "Hello, World!" (Trust me, it's not fun, but it's essential). Find the package manager, which should look like this
Where the magic happens...
Now, right click the side that has the tab that says, "Package manager", and select "New". This should lead into a great many things, such as "Project..." and probably "Java Project". If Java Project is shown, then just click it. If not, click "Project..." and find it. Please note that "Project..." does not mean that the person who typed it was depressed or anything, but it is just leading on to other things. Now, when you try to create a project, it looks like a form that you need to fill out. It's not paperwork, it's just a program. Now, type in "Hello World" into the package name. It should now look like this:
Creating your Java Project

Click 'finish' after you have come up with your name. Now, you can right click 'src' (your source code) and create a new Package name and Class name.

This is the part where I will describe how to do the programming of this program.
Hello World:
Well, the Hello World program  is very simple. When you go onto the 'Create a new class' screen, which should look like this:
Click the circled button for a very quick way to finish
Now, the button that has 'public static void main(String[] args)' is very important. Clicking it will input the code in the actual class, so I recommend you click it, or you could type it. Once you do that, a class should appear, entitled after what you named it.  If you did click on the button, as I recommended, your product should look like below:
If you look on the bottom part of the page, you see the word 'Warnings (3 items)'. You don't have to worry about these yet, but you should really worry about these things. I mean, they are warning you about something, almost always bad or questionable. For example, if you had a boulder coming towards you at 150 mph, it would be really nice for a warning once in a while. These are like that, but better, as they can't kill you, but can significantly cause problems in various areas.
Type in System.out.println("Hello, World!"); in between the two squiggles, open and close ( { } I call them squiggles). It should look like this:
You are almost finished! Aren't you glad that you don't have to look at this 'amazing' program anymore???
Alright, now, click run. In the "Project" box, it should say, "Hello, World!".

And that is what Hello World is. I think I should win a medal because this over explains how to program it. 

Thank you for reading, dear reader, and have a good day.

=-The Rich Man known as Thursday (Note that I am not actually rich, but it's just an attitude towards everything)