aspose file tools*
The moose likes Beginning Java and the fly likes Confuse BufferedReader type with String Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Confuse BufferedReader type with String" Watch "Confuse BufferedReader type with String" New topic
Author

Confuse BufferedReader type with String

nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
Could anybody explain to me why i have the incompatible type error when compile this program. inLine Variable is in String so i thought it would ok if i use inLine to send as a string to CookiesPersistant(inLine). But it perform wrror. Why?

Please help me..i blurr how to solve this. I am new in Java.

[ edited to preserve formatting using the [code] and [/code] UBB tags -ds ]
[ September 22, 2004: Message edited by: Dirk Schreckmann ]
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
change this line
static Boolean CookiesPersistant(String str)

to this
static boolean CookiesPersistant(String str)
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, nani aman!

When posting code, please be sure to surround the code with the [code] and [/code] UBB Tags. This will help to preserve the formatting of the code, thus making it easier to read and understand.

Concerning Michael's suggestion, depending on the version of Java you're using, you might need to do what he suggested. If you're using Java 2 v5, then it's not a concern. If you're using some earlier version of Java, then it is a concern.

If you're not sure, to determine which version you're using, run the following command.

javac -J-version

If you see version information for something less than 1.5, then using a Boolean where a boolean is required is a problem. You could go with Michael's suggestion, or make a call to the booleanValue() method of your Boolean.

The code you posted is rather incomplete. It doesn't compile, and when trying to compile it, it doesn't produce the error message you initially posted about. Fixing the code so that it does compile (by adding some brackets, a catch block, some imports, and a variable declaration) - well then it compiles and the error message you initially posted about remains unexperience by me.

Perhaps you could post a more complete code example.
[ September 22, 2004: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
Thanks a lot. Its help.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Did you figure something out? What was it?
nani aman
Ranch Hand

Joined: Sep 22, 2004
Posts: 33
I chage Boolean with boolean and my codes compile. Boolean and boolean is 2 different thing right. But i still can't figure out what the different.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
boolean is a primitive data type. Things of this type are just data - i.e. values.

Boolean is an object data type. Things that are objects contain data (like primitives and other objects) and have behaviors (as defined by their methods).

Rather than have me try to repeat what any good introductory Java programming material should cover, let me direct you towards some good free resources:
  • Sun's Java Tutorial
  • Introduction to Computer Science using Java by Bradley Kjell
  • Introduction to Programming Using Java by David J. Eck
  • Dick Baldwin's Java Programming Tutorials
  • Interactive Programming In Java by Lynn Andrea Stein
  • Bruce Eckel's Thinking In Java
  • JavaRanch's own Campfire Stories
  • Allen B. Downey's How To Think Like A Computer Scientist
  •  
     
    subject: Confuse BufferedReader type with String