Try getting your own book - if you don't have any previous experience in programming, the Dummies series are very helpful - they don't assume you know anything starting out, and explain things very clearly.
http://www.amazon.com/Beginning-Programming-Java-Dummies-Computer/dp/0764588745/ref=pd_bbs_sr_2/002-4268927-6908840?ie=UTF8&s=books&qid=1173479619&sr=8-2
2007-03-09 09:33:52
·
answer #1
·
answered by Rex M 6
·
0⤊
0⤋
Accessor methods:
These are simple. For example, assume you have the following attributes in a class:
private int num;
private String word;
You would access them thus:
public int getNum()
{
return num;
}//You just use the simple reserved word "return" -- that's all it is!
public String getWord()
{
return word;
}//See how the data type is included in the header? Make sure that type is right!! Also, remember that if you include a data type in the header (as opposed to "void"), there MUST be a return statement of some sort within the method.
Data Manipulation Methods:
I assume this is what I know as "mutator" methods. They're pretty simple, too. Say you want to change the value of int num, from our previous accessor list, to a parameter the programmer passes in. You'd do it thus:
public void changeNum(int n)
{
num = n;
}//See how this time, there's a "void" in the header instead of a data type? That's because you aren't returning anything. Mutator/data manipulation methods can be much more complicated than this, using prompts, etc., but this is the basic format.
This reference:
The "this" reference refers to the object in question. It's used like this.getNum();
You'll use this reference inside a method which uses another method. For example, if you're implementing the Comparable class, making a compareTo method, the method will be called like:
one.compareTo(two);
Inside the body of the compareTo method you'd have written, you could have something like:
return this.getNum - parameter.getNum;
"This" refers to "one," the object that called the method.
Equals method:
When you compare strings, you can't use the == sign, the != sign, etc. You have to use a .equals method instead. It looks like this:
(if String1.equals(String2))
If the strings are equal, the method will return "true," which means it's boolean in nature.
Static class members:
This is simple -- these are members of a class which do not change based on the object. Does that make sense? The "main" method is an example, one you use all the time -- i.e.,
public static void main(String args[])
{...}
Look familiar? I hope so.
Graphical objects, enumeration types:
This is a big subject...What exactly do you not understand?
A class definition is simply the barebones of a class, with the attributes, method names, etc, but no implementation code. For example:
class Book
{
private int pages;
private String title;
public Book()
{implementation}
public Book(int p, String t)
{implementation}
public void changePages(int p)
{implementation}
public void changeTitle(String t)
{implementation}
public int getPages()
{implementation}
public String getTitle()
{implementation}
}
See how none of the code is written out, just the attributes and headers? That's a class definition.
2007-03-09 17:42:54
·
answer #2
·
answered by lydia 2
·
0⤊
0⤋
You've asked for a lot of information there. Do a search for Object Oriented Programming and try to find a result that is brief but will give you the basic foundation.
A very short explanation is that methods are functions in your code and they are talking about "accessing" resources on your computer and manipulating data with those functions. Please seek help from the professor or teacher if possible. It's not hard once you understand it, but if you don't you will be left behind for the rest of the class. Hope this helps.
2007-03-09 17:36:37
·
answer #3
·
answered by SwazooGuy 2
·
0⤊
1⤋
You need to get Ivor Horton's book "Beginning Java 2". It is, by far, the best beginning Java book available. It is written in a very down to Earth way and does not assume that you know anything specific about programming. Amazingly, it is also a fantastic reference for the future. I have been developing software in Java to 10 years and I still occasionally reference this book. Definitely money well spent.
2007-03-09 17:54:56
·
answer #4
·
answered by Math Guy 4
·
0⤊
1⤋