LostGamerz
Java guides and basic tutorials 1296785282
LostGamerz
Java guides and basic tutorials 1296785282
LostGamerz
Would you like to react to this message? Create an account in a few clicks or log in to continue.



 
HomePinoy VendeTaLatest imagesRegisterLog in

 

 Java guides and basic tutorials

Go down 
AuthorMessage
Crowd™
Administrator
Administrator
Crowd™


Join date : 31/01/2011
LostPoints : 10383
Thanks & Rep : 28
Posts : 229
Age : 33
Location : 6ret
Warning Level : Java guides and basic tutorials WarningBar-Gloss1

Java guides and basic tutorials Empty
PostSubject: Java guides and basic tutorials   Java guides and basic tutorials Icon_minitimeSun Aug 05, 2012 3:52 am

So this is my new tutorial . So hope you listen for my class ahm.

What is Java?

Quoting Wikipedia:
Java is a programming language originally developed by James Gosling at Sun Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is general-purpose, concurrent, class-based, and object-oriented, and is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere". Java is considered by many as one of the most influential programming languages of the 20th century, and widely used from application software to web application.

There were five primary goals in the creation of the Java language:
It should be "simple, object oriented, and familiar".
It should be "robust and secure".
It should be "architecture neutral and portable".
It should execute with "high performance".
It should be "interpreted, threaded, and dynamic".
Syntax

The syntax of Java is largely derived from C++. Unlike C++, which combines the syntax for structured, generic, and object-oriented programming, Java was built almost exclusively as an object oriented language. All code is written inside a class and everything is an object, with the exception of the intrinsic data types (ordinal and real numbers, boolean values, and characters), which are not classes for performance reasons.

See also
[Only admins are allowed to see this link]

Official Website:
[Only admins are allowed to see this link]

Java Programming Tutorial

Hi everybody, MrStar here.
I found it very interesting the other day that multiple threads were made with topics as what should my first programming language be or what would I choose, java, c or c++?. Well, I'm here to help you a bit with that choice. Since I tried some programming languages in the past, being c, c++, python, visual basic.net and java, I found that Java was the easiest to understand as a first language. Maybe the reason for that is because it’s a school class I'm following.

This might not look very good, typed in a forum, but i'll be uploading pdf's of it, that might make things a little more clear to you guys..
To start, I could give you a brief history about java, but I tend to believe that that's not very interesting when you really want to start programming. Plus, all the information is on Wikipedia . It might be interesting to say that Java is platform independent, meaning that in fact, you can use the same code on a windows box, as you would use it on a Unix/Linux or all other flavors you prefer. Second of all, Java is OO. OO stands for Object oriented, and is a very good way of programming.

Object Oriented?
A basic understanding of OO are the objects. The best way for me to understand an object is to work with an example. I'm going to try to explain this with the example car. Car is abstract, there are many cars in many shapes and sizes with different functions. Every car has a color, license plate, amount of doors, length. We call these things, attributes. Also, every car has different functions. For example drive, stop, accelerate, turn… These functions are called methods. All cars belong to the class Car, but they are all different. A BMW isn't the same as a Hyundai, though they are both cars. A car is in fact a blueprint of the actual concrete BMW. Its an instance of car.

The JDK.
To start with java, you need to have your programming environment. Download the Java Development Kit here: [Only admins are allowed to see this link] . Second of all, I’d recommend Textpad, which is a text editor for windows with build-in syntax highlighting and compile/run buttons. Get it here: [Only admins are allowed to see this link] .

The real thing: Hello World!
Because I know everyone who's reading this is eager to start with the basics, I'm no longer going to let you wait. I'll just start like everyone does by giving you an example of the Hello World basic application.
Code:

public class Helloworld
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}

The first thing you see here in this example is:
Code:
public class Helloworld { }
This is the header, whatever will be within the "{}" will be called the body. The classname Helloworld should be exactly the same as how you call your .java file. Thus our .java file will be Helloworld.java. It is called our identifier, it doesn't contain spaces and never starts with a number! Above all that it's case sensitive, thus making Hello != hEllO.
The second object we see is:
Code:
public static void main(String[] args){}

This is your holy sentence. This is what you'll remember from now on, till the end of you days, because almost every program you’ll write in java, will have this line. This will execute the java program.
The last thing we see in the body is:
Code:
System.out.println("hello World!");

This will open a CLI and print Hello World! on your screen. Println stands for print line, and is not the same as print. Note that it ends with ";". All instructions end with ";".

What to do with this?
There are 2 options.
1) You use textpad, which is easy to work with, you'll get the hang of it after 3minutes.
2) Type your code in wordpad, save it as identifier.java, use cmd to cd to the file. Use javac to compile it. (javac Helloworld.java). Then you use java Helloworld to execute it.

System.out.print(ln)?
Remember before when we used:
Code:
System.out.println("Hello world!");

Well, we could have done the same thing with System.out.print("Hello world!"); The difference between print and println, is that after the last in println, there will be a return. And so, creating a new line. Look at this code.
Code:
System.out.print( "Hello " );
System.out.println( "World!" );

will print:
Hello World!

Code:

System.out.println("Young programmer!");   


Young programmer!

There are some special symbols you can use with println and print. They all have a meaning.
\n = return
\t= tab
\\ = to print a
\ = to print a

For example:
Code:

System.out.println("Hello\tWorld\nYoung\tProgrammer");

Will print => Hello World
Young Programmer
Print
As a third print method, there is also the printf method. This is a very extended print method which gives you a lot of possibilities. I'm not going to discuss them, because that would be too much work and to be honest, I'm not much of a fan of it, though it could help an awful lot. I'd recommend you to read information on the sun website about this. Or maybe I'll discuss them later if my tutorials got some good comment.
Back to top Go down
https://pinoyvendetta.forumtl.com
 
Java guides and basic tutorials
Back to top 
Page 1 of 1
 Similar topics
-
» Beginner Java: Displaying a 2D background
» Java Beginner code written better
»  Basic Decryption Tutorial
» Basic Decryption Tutorial

Permissions in this forum:You cannot reply to topics in this forum
LostGamerz :: Coding Section :: Java Language, JVM, and the JRE-
Jump to: