Tuesday, June 16, 2015

Java 101 - 01 What is Java and What is it Made of?

 Whether you're a computer Science major or just someone thinking of picking up a pastime skill, this post will explain what Java is and also give some beginning introduction to it. :)


An Introduction to Java's birth and life:
Java was born on June 1991. Created by James Gosling, Mike Sheridan, and Patrick Naughto. Apparently I learned through some research that Java was created for the purpose of television improvement but it was too advanced to be used during that time. It was originally named Oak after some oak tree. Later, the name changed to green during their green project and then changed to Java after the coffee. Something I know about Java is that things are being added and have been added since the creation of it and everything accumulated from all these years is still in the language. Reason of this that there were five established goals at the time they created it.

1. It must be "simple, object-oriented and familiar"
2. It must be "robust and secure".
3. It must be "architecture-neutral and portable".
4. It must execute with "high performance".
5. It must be "interpreted, threaded, and dynamic".

With these rules the now commonly used language was birthed. If you like to know more about the creator or the language, visit the wiki or webpage I have linked to each of the creators.

How this little tutorial is going to work:
In this tutorial (or any future tuts) I will try to go through the talking step by step, where each tutorial will go along the development of a small program. Each step will include little snippets of code, where at the end I will make a code combination. The final code combination allows you to see what you have done after the whole tutorial, as well as see what you have learned. These tutorials, hopefully, can be easily followed and the code snippets can be copied into your own compiler for you to learn.

Suggestion: Use a text editor or a simple compiler program to help you with the code. In our University Java class we use Dr. Java. Usually the jar file is easier to use. It's also portable so you can stick in on a flash drive.

Straight to the basics:
Now to the fun. We will get started with the basic syntax since all background information is provided in the section above.

Syntax:
Java code is case sensitive, so beware your capitalization or your keyboard's auto-capitalization features. Many times my students go nuts over their code error forever to only find that it was one letter. ONE LETTER!!!!

Naming Conventions:
Naming conventions are just the rules of how to keep organized names of different things. Class names should have the first letter capitalized,with each word's first letter also capitalized.
class MyClass{
}

Method Names:
Method names should have the first letter lowercase,with other words' first letter capitalized.
 public void thisMethodNotAllLowercase(){

}

The Main Method:
The main method is a mandatory part of a java program; it is used to tell the Java program where to go and what to do.
public static void main(String []args){

}

Program File Naming:
The name of your program file should always be named the same as your class name. Going with the class name example we put above, our program file would be named MyClass.java


Keywords:
Keywords are special words that are used to "command" the program. Words like class, public, or static(like those used in example above). So, don't use these keywords as names unless you want your compiler to yell at you. And you don't want your compiler to yell at you.

Summary:
We learned about how to name things in our Java program in this tutorial; don't worry I will explain what class method and all that jazz is in a later tutorial! But, here is the end code if you want to try it anyways.
//this is a comment. We'll talk about it later don't worry.
//This is the Myclass class naming
class MyClass{
//This is the main method we always need
public static void main(String []args){

}
//This is some random method we made, notice the capitalization rules.
public void thisMethodNotAllLowercase(){

}
}


If I made any errors please point out to me with comments! I'm human, despite what my nephew says; Unfortunately I make mistakes too.

0 comments:

Post a Comment