Link to home
Start Free TrialLog in
Avatar of sraveend
sraveend

asked on

java programming

Please give me difference between class and Class
Can i store non-primitive type of a field ,class in a class?  
Avatar of Mick Barry
Mick Barry
Flag of Australia image

> Please give me difference between class and Class

what exactly are you referring to?

> Can i store non-primitive type of a field ,class in a class?

yes

public class A
{
   private B field;
}
Avatar of expertmb
expertmb

class it can be variable name.

SOLUTION
Avatar of expertmb
expertmb

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
class is a keyword used to declare a java class.
Class is a inbuild class in java.lang package
class  is used in two places
either declaring a class
like
public class A
{
   private B field;
}

or it can be used to get the class object of an object :)
like this
obj.class.getName();

Class is a class in java.lang package
"Instances of the class Class represent classes and interfaces in a running Java application"
>class it can be variable name.

NO. It's a java keyword and indicate to declare a class.

Class (with C uppercase) is a particular class used into java program. See here the doc:
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Class.html
>class it can be variable name.
wrong comment from me apologize for tht
>>Can i store non-primitive type of a field ,class in a class?  

Alternatively, if you mean this, then you can

public class A {
    private Class clazz;
}
The member variables (fields) can be of type primitives, or a particular class.
The class java.lang.Class is no different to any other class in this respect.

What the class java.lang.Class provides is details about a particula java class.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial