Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-09-2003, 05:19 PM   PM User | #1
VivaAvril
New to the CF scene

 
Join Date: Jul 2003
Location: Los Angeles
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
VivaAvril is an unknown quantity at this point
Java

I will be taking a class on Java when I get to college in a few months. I would really love to be familiar with it before I enter college, and I would really appreciate it if people could give me the fundamentals of it such as which vocabularies are important and will be used often and their definition (in comprehensible words of course).

I tried checking some tutorials on the web, and I got lose even more. LOL When I checked for the definition of class, it says
Quote:
A class--the basic building block of an object-oriented language such as Java--is a template that describes the data and behavior associated with instances of that class. When you instantiate a class you create an object that looks and feels like other instances of the same class. The data associated with a class or object is stored in variables; the behavior associated with a class or object is implemented with methods. Methods are similar to the functions or procedures in procedural languages such as C.
And with me having no experience on programming before, I am seriously lost and worried when I enter my Java class in college.

Again, I would appreciate any help.

Thanks! =)
VivaAvril is offline   Reply With Quote
Old 07-09-2003, 05:59 PM   PM User | #2
Jason
Regular Coder

 
Join Date: Feb 2003
Location: California
Posts: 925
Thanks: 0
Thanked 0 Times in 0 Posts
Jason is an unknown quantity at this point
think of it like this, when writting a paper there are paragraphs....so the paper it self is the "class" and the paragraphs are the "methods". The whole, OO (object oriented) bit about java means that when you refer to different variables you can use a "." or dot notation e.g. you make a container object called an array and you want to know its length, you could say something like array_name.length to get an integer value of its length....does that better explain a few things?


Jason
Jason is offline   Reply With Quote
Old 07-09-2003, 06:20 PM   PM User | #3
VivaAvril
New to the CF scene

 
Join Date: Jul 2003
Location: Los Angeles
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
VivaAvril is an unknown quantity at this point
obviously, it's better than the other definition I got. lol

but I'm still confused a bit. What exactly does a class do, and what exactly does a method do? Like how do you use those two functions (if that's what they are called). From the same site I got the definition of class from, it also provided an example.
Quote:
/**
* The HelloWorldApp class implements an application that
* simply displays "Hello World!" to the standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); //Display the string.
}
}
The first 4 lines would be comments. The fifth starting with class HelloWorldApp is where I start to get confused. When you mentioned array_name.length in your recent post, is that a method right there? If so, does that mean System.out.println("Hello World!") is also a method from the example in the quotes? =)
VivaAvril is offline   Reply With Quote
Old 07-09-2003, 06:52 PM   PM User | #4
Jason
Regular Coder

 
Join Date: Feb 2003
Location: California
Posts: 925
Thanks: 0
Thanked 0 Times in 0 Posts
Jason is an unknown quantity at this point
ok in that example you have a few things there...you have a class, a main function and that OO stuff I talked about (System.out.println....)
the class basically is saying that all things within that following curly brace are variables that can only be accessed within there. The main method is where all the execution of the program will take place. You can have others that get called in the main but they are only looked at if they are mentioned in the main. That System.out.println is saying that you are making a system call to output something and the println is saying that what is being printed will go on a single line...


Jason
Jason is offline   Reply With Quote
Old 07-15-2003, 04:53 PM   PM User | #5
ObiwanJebroni
New Coder

 
Join Date: Jun 2002
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
ObiwanJebroni is an unknown quantity at this point
When you want to put something in computer memory, the computer needs to make room for it. You will see in Java that you need to declare variables by saying what kind of data it will hold. For instance, you have "int" for integers and "string" for strings of characters.

A class is basically a user defined data type. A class becomes the outline by which all variables of that type will follow. In OO lingo, an object is what you get when you create a new variable of the new class that you've made.

Classes have two components to them: methods and members. Member is basically the data that can be held. These can be any types that you've defined "int", "double", "string", etc. Methods are the functions in the class to manipulate that data.

For instance, take this example:

class aDog
{
public void bark() {System.out.println("Woof");}
public void whatsMyAge() {System.out.println("I am " + myAge);}
private int myAge = 10;
}

You have data and you have methods that can operate on that data. In general, the idea of objects is to provide an interface for the end user. The public, private, and protected keywords determines what part of your program can access that method or member. The reason for keeping some data private is because of a concept called information hiding; something that's used to keep the data in an object in tact and to make errors less likely.

For every program, the compiler specifies an entry point. This tells the system that you're running it from where to begin execution. In your example, the Java compiler specifies main() as the entry point for the program, so it begins executing commands there.

Hope that helped.
__________________
-Obiwan Jabroni
May the Schwartz be With You
ObiwanJebroni is offline   Reply With Quote
Old 08-03-2003, 11:45 AM   PM User | #6
dmp
New to the CF scene

 
Join Date: Aug 2003
Location: UK
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
dmp is an unknown quantity at this point
I would recommend Bruce Eckel's *free* electronic book 'Thinking in Java'.

http://www.mindview.net/Books/TIJ/

It provides a good basic introduction.

DMP
dmp is offline   Reply With Quote
Old 08-06-2003, 11:13 PM   PM User | #7
Drakain Zeil
New Coder

 
Join Date: Jul 2003
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
Drakain Zeil is an unknown quantity at this point
Quote:
I would recommend Bruce Eckel's *free* electronic book 'Thinking in Java'.

http://www.mindview.net/Books/TIJ/

It provides a good basic introduction.

DMP
I recommend the www.DMOZ.org directory, they have almoste everything in there, minus spam because its basicly 100% human edited.

Also I would say "Java for dummies" I got it at the age of (I think) 8, I'm 15 now. It really helped me get a footing into the Java world.
Drakain Zeil is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:01 PM.


Advertisement
Log in to turn off these ads.