Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 22nd, 2003, 09:28 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to chikodi
Default casting double to String.

Hi,

Why wouldn't the following compile?

out.println("<tr><td>" + (String)tokenizer.nval + "</td>");

Compiler message is "inconvertible types".

Thanks.

nbc
Reply With Quote
  #2 (permalink)  
Old October 22nd, 2003, 10:16 AM
Registered User
 
Join Date: Jun 2003
Location: , , Ireland.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm guessing (since you don't mention what type of object the tokenizer is) that the tokenizer is a StreamTokenizer object. The tokenizer.nval is a double, so you are trying to cast a double into a String which you can't do in Java! Thats why you get the error message.
Reply With Quote
  #3 (permalink)  
Old October 23rd, 2003, 03:50 AM
Authorized User
 
Join Date: May 2003
Location: New Delhi, Delhi, India.
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
Please specify which Object does the tokenizer.nval contains.If it's an Integer or Double or Long you can use the toString() method of these class to get the String representation. If tokenizer has some primitive data type the u can use the

String.valueOf(double d);

parameter will change depending on the data type

Regards

Yashraj Chauhan
Java\J2EE Specialist
Wiley Support Team
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing Double Quotes from a string Durkee VB.NET 2002/2003 Basics 12 October 4th, 2007 01:10 PM
Casting String array to string Samatha ASP.NET 1.0 and 1.1 Professional 1 December 5th, 2006 07:46 AM
Casting System::Object __gc * to System.Double[] nepsat Visual C++ 3 November 19th, 2005 12:51 PM
String to Double conversion mkpriya VS.NET 2002/2003 3 October 21st, 2003 06:26 AM
double to string? chris97b Visual C++ 4 September 23rd, 2003 03:34 PM



All times are GMT -4. The time now is 06:53 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.