This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes What's This compile error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What Watch "What New topic
Author

What's This compile error?

Gary Farms
Ranch Hand

Joined: Jun 24, 2000
Posts: 57
When I compile the following Gary.java program, I get an error stating: Incompatible type for declaration. Can't convert java.lang.String to string. Why??? Here's my simple Gary.java program:

public class Gary
{
static public void main(String args[])
{
string tmp = "boy";
}
}
Also, what class(if any) are the primitives such as integer in?
Insn't everything a subclass of class Object?
Bill Graf
Greenhorn

Joined: Apr 07, 2001
Posts: 4
String needs a capital S.
Originally posted by Gary Farms:
When I compile the following Gary.java program, I get an error stating: Incompatible type for declaration. Can't convert java.lang.String to string. Why??? Here's my simple Gary.java program:

public class Gary
{
static public void main(String args[])
{
string tmp = "boy";
}
}
Also, what class(if any) are the primitives such as integer in?
Insn't everything a subclass of class Object?

Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Capitalize the word String. Java is case sensitive.
Primitives are called primitives because they are not objects. So you will not find them in any class.
Java is ALMOST a pure OO language, except for the primitives which were allowed for efficiency, and for the String Literal behavior which is a shortcut and adds efficiency, and arrays which have some specific non-OO behavior other than that it is completely OO.
Notice that C++ is not a pure OO language, VB is not even CLOSE, etc.
There ARE a few pure OO languages out there though.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Christine Alfano
Greenhorn

Joined: Jan 30, 2001
Posts: 1
In order to declare a String the 'S' must be capitalized. Make the change and your compilation error will disappear.
Originally posted by Gary Farms:
When I compile the following Gary.java program, I get an error stating: Incompatible type for declaration. Can't convert java.lang.String to string. Why??? Here's my simple Gary.java program:

public class Gary
{
static public void main(String args[])
{
string tmp = "boy";
}
}
Also, what class(if any) are the primitives such as integer in?
Insn't everything a subclass of class Object?

Steve Lemay
Greenhorn

Joined: Apr 12, 2001
Posts: 2
If you want to deal with primatives like objects then use the wrapper classes, you can find these in the java.lang package, there called the same as primative's but with capitilization (ie Integer).
And yes all classes are ultimatley subclasses of object
 
GeeCON Prague 2014
 
subject: What's This compile error?