Results 1 to 7 of 7
Thread: Newbie Questions
- 02-22-2011, 02:35 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
- 02-22-2011, 02:43 AM #2
Type is simply that, the type of the variable. For example int, long, double, String, Point, Foo, Bar etc. The first three are primitive types. The last four are reference types (classes).
It depends upon where your declare them.What is the difference between a variable and an instance variable?
An instance variable is so called because each time you create an object of that class they each get their own instance of that variable. The class variable means that it belongs to the class and not an instance. So each object you create uses the same variable. The difference is very important to understand. Lastly the local variable is local to that code block (if statement, loop or method) and cannot be used outside of that code block.Java Code:class Foo { String name; // instance variable static int count; // class variable public void doStuff() { int thingy = 0; // local variable } }
- 02-22-2011, 03:55 AM #3
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Oh I remember that, so an example sentence I am struggling with is "An object of type String is a sequence of characters." Then talks about string literals with examples ("2468") and ("I must/n go home").
to summarize, instance variable is a duplicated variable every time the same class is made?
Class variable is a variable only made once but used by classes in need?
local variable is found and used in a certain code block.
how to superclass and subclass work for these variables? How do you tell them apart since variables don't have headers.
- 02-22-2011, 03:58 AM #4
- 02-22-2011, 04:05 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
- 02-22-2011, 04:08 AM #6
- 02-22-2011, 04:17 AM #7
Member
- Join Date
- Feb 2011
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Need help with some questions
By El_Davidos in forum New To JavaReplies: 5Last Post: 11-23-2010, 10:13 AM -
Several newbie questions, applet help mostly
By gymangel812 in forum New To JavaReplies: 4Last Post: 02-16-2010, 02:00 AM -
Couple of newbie questions
By ananasman in forum New To JavaReplies: 11Last Post: 11-20-2008, 11:54 PM -
Some newbie questions about shortcuts
By nefigah in forum EclipseReplies: 2Last Post: 07-29-2008, 08:25 AM -
Newbie with questions
By buzzdsm in forum New To JavaReplies: 14Last Post: 06-05-2008, 04:11 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks