• Post Reply Bookmark Topic Watch Topic
  • New Topic

Variables and Methods  RSS feed

 
Seth Copeland
Greenhorn
Posts: 3
Firefox Browser Java Notepad
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So i understand what a class is, its Instance Variables and Methods. So are primitive variables and object reference variables just the two different types of Instance variables? And is using the dot operator after a object reference variable a method? Also what does char do?
 
Junilu Lacar
Sheriff
Posts: 11494
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seth Copeland wrote:So are primitive variables and object reference variables just the two different types of Instance variables?

Prior to Java 8, yes. As of Java 8, you could conceivably have instance variables that refer to methods (method references) and lambda expressions, which I suppose you could still consider as "objects", except they're not or at least I don't think they're equivalent.

is using the dot operator after a object reference variable a method

It depends on what comes after the dot operator. In general, it tries to access a member of the instance referenced by that variable. The instance member can be a field/attribute or a method that is in scope or visible at the time the reference is made. If you try to access a field/attribute, it's value will be returned. If the name of a valid method follows the dot operator, that method will be invoked/executed.

what does char do?

http://docs.oracle.com/javase/tutorial/java/data/characters.html
http://docs.oracle.com/javase/7/docs/api/java/lang/Character.html
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seth Copeland wrote:So are primitive variables and object reference variables just the two different types of Instance variables?

The type of a variable, and what kind of variable it is (an instance variable, a class variable or a local variable) are different aspects of a variable.

Variables have a type, which is either one of the eight primitive types (byte, short, int, long, float, double, boolean, char), or a reference type (a reference to an object).

You can use variables in different places - a variable declared inside a method is a local variable, a variable declared at class level is an instance variable, and a variable at class level that is static is a class variable. This is independent of its type. These different kinds are explained in the Variables tutorial. What static means, is explained in Understanding Class Members.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!