hai,
I want to convert String to int.My coding is like this, -
rs=stmt.executeQuery("select a from mailtable");
-
rs.absolute(-1);
-
-
String id=rs.getString("a");
-
System.out.println(id);
-
-
id= id.substring(3,(id.length()));
-
System.out.println("value of id is "+ id);
-
at last this id having an numeric value ,I want to convert this to int. After this i want to add 1 to that int value.How to do this please help me.
This is not working. It gives NumberFormatException. Please anyone can help me.
This is very urgent for me.
13 5305
hai,
I want to convert String to int.My coding is like this, -
rs=stmt.executeQuery("select a from mailtable");
-
rs.absolute(-1);
-
-
String id=rs.getString("a");
-
System.out.println(id);
-
-
id= id.substring(3,(id.length()));
-
System.out.println("value of id is "+ id);
-
at last this id having an numeric value ,I want to convert this to int. After this i want to add 1 to that int value.How to do this please help me.
This is not working. It gives NumberFormatException. Please anyone can help me.
This is very urgent for me.
If you want the ASCII value: -
System.out.println((int) id.charAt(0));
-
parseInt would give you a 1 if used with the String "1".
If you want the ASCII value: -
System.out.println((int) id.charAt(0));
-
parseInt would give you a 1 if used with the String "1".
Look He is not Looking for ASCII Value.
He wants to convert into Number.
Kind regards,
Dmjpro.
Look He is not Looking for ASCII Value.
He wants to convert into Number.
In that case, what output does
create?
id= id.substring(3,(id.length()));
Are you sure that the id is equivalent to Number.
Look The NumberFormatException thrown when the Input String is not Equivalent to a number.
One more thing If you want to cut a String from a Starting Index up to Last then it's enough with id.substring(3).
Anyway, try to check that the return String whether contains any Non-Digit.
If it is then this Exception must be thrown.
Ok, Best of Luck with your try.
Kind regards,
Dmjpro.
Are you sure that the id is equivalent to Number.
Look The NumberFormatException thrown when the Input String is not Equivalent to a number.
One more thing If you want to cut a String from a Starting Index up to Last then it's enough with id.substring(3).
Anyway, try to check that the return String whether contains any Non-Digit.
If it is then this Exception must be thrown.
Ok, Best of Luck with your try.
Kind regards,
Dmjpro.
Thanks for your reply.
I want to convert into integer. And then I sure it contains the value number.It is getting from the database.After three posisions it is only have numeric values only.And Also I checked that value using print statement it prints number.
After converted into int ,I want to add 1 to that. There is any other solution for this.
Thanks for your reply.
I want to convert into integer. And then I sure it contains the value number.It is getting from the database.After three posisions it is only have numeric values only.And Also I checked that value using print statement it prints number.
After converted into int ,I want to add 1 to that. There is any other solution for this.
Could you send me Stack Message you got in your Console.
I mean the total Exception Message.
Could you sen me please?
Kind regards,
Dmjpro.
hai,
I want to convert String to int.My coding is like this, -
rs=stmt.executeQuery("select a from mailtable");
-
rs.absolute(-1);
-
-
String id=rs.getString("a");
-
System.out.println(id);
-
-
id= id.substring(3,(id.length()));
-
System.out.println("value of id is "+ id);
-
at last this id having an numeric value ,I want to convert this to int. After this i want to add 1 to that int value.How to do this please help me.
This is not working. It gives NumberFormatException. Please anyone can help me.
This is very urgent for me.
Not all Strings can be converted to integers. The string you're trying to convert to a number is not a number. That's why you got the exception.
Not all Strings can be converted to integers. The string you're trying to convert to a number is not a number. That's why you got the exception.
-
String id="EAM9";
-
id= id.substring(3,(id.length()));
-
System.out.println(id);// it will print 9.
-
//after this i want to convert id into integer.
-
-
String id="EAM9";
-
id= id.substring(3,(id.length()));
-
System.out.println(id);// it will print 9.
-
//after this i want to convert id into integer.
-
I tested this Code.
And it works fine. -
String id="EAM9";
-
id= id.substring(3,(id.length()));
-
System.out.println("Dmjpro: " + id);
-
Sstem.out.println("Debasis Jana: " + Integer.parseInt(id));
-
Kind regards,
Dmjpro.
-
String id="EAM9";
-
id= id.substring(3,(id.length()));
-
System.out.println(id);// it will print 9.
-
//after this i want to convert id into integer.
-
Can you print out the *length* of that id String as well? I suspect some trailing
spaces or non-printing character there.
The example as it is runs fine for me.
kind regards,
Jos
Can you print out the *length* of that id String as well? I suspect some trailing
spaces or non-printing character there.
The example as it is runs fine for me.
kind regards,
Jos
yeah Jos you are right.
There may be some leading or trailing spaces or non-printing Chanracter.
Kind regards,
Dmjpro.
It is working fine.Thank you very much for all your responses.
It is working fine.Thank you very much for all your responses.
So you didn't change anything and all of a sudden it works fine? I hope you don't
mind if I don't believe that; care to elaborate on what you changed? It may come
in handy for others who are struggling with the same problem and try to google
for it; google might point them to this thread.
kind regards,
Jos
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joel Moore |
last post by:
Maybe I'm just easily baffled after an all-nighter but I can't seem to
figure out how to represent a BitArray as a hexadecimal string.
For example:
Dim outputBank As New BitArray(8)
...
|
by: Eric Lilja |
last post by:
Hello, I've made a templated class Option (a child of the abstract base
class OptionBase) that stores an option name (in the form someoption=) and
the value belonging to that option. The value is...
|
by: aevans1108 |
last post by:
expanding this message to microsoft.public.dotnet.xml
Greetings
Please direct me to the right group if this is an inappropriate place
to post this question. Thanks.
I want to format a...
|
by: Convert TextBox.Text to Int32 Problem |
last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
|
by: patang |
last post by:
I want to convert amount to words. Is there any funciton available?
Example:
$230.30
Two Hundred Thirty Dollars and 30/100
|
by: patang |
last post by:
Could someone please tell me where am I supposed to put this code. Actually
my project has two forms. I created a new module and have put the following
code sent by someone. All the function...
|
by: GM |
last post by:
Dear all,
Could you all give me some guide on how to convert my big5 string to
unicode using python? I already knew that I might use cjkcodecs or
python 2.4 but I still don't have idea on what...
|
by: tshad |
last post by:
I am trying to convert a string character to an int where the string is all
numbers.
I tried:
int test;
string stemp = "5";
test = Convert.ToInt32(stemp);
But test is equal to 53.
|
by: Marco Nef |
last post by:
Hi there
I'm looking for a template class that converts the template argument to a
string, so something like the following should work:
Convert<float>::Get() == "float";
Convert<3>::Get() ==...
|
by: Debadatta Mishra |
last post by:
Introduction
In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |