Results 1 to 17 of 17
- 08-19-2011, 03:22 AM #1
Member
- Join Date
- Mar 2011
- Posts
- 52
- Rep Power
- 0
-
-
If you need more specific help, you'll want to give us a lot more information about your problem including your code, your data, what you're trying to achieve and what's not happening. Please read the link in my signature link on how to ask smart questions to see what kind of information will help us best help you.
- 08-19-2011, 03:37 AM #4
Of course you get an error. What integer value is represented by an empty String? If you want to avoid this error then check the String length before parsing it.
- 08-19-2011, 05:24 AM #5
Here's an empty string for you.
String str = null;If you aren't programming in Java, well that's just too bad.
I'd rather be using Ubuntu.
- 08-19-2011, 05:31 AM #6
Yet again you post incorrect information.
NULL IS NOT AN EMPTY STRING.
Null is null and nothing else. An empty string on the other hand is an actual object that contains no characters.
The output of the above is false false because NULL IS NOT AN EMPTY STRING.Java Code:String emptyString = ""; String nullString = null; System.out.println(emptyString == nullString); System.out.println(emptyString.equals(nullString));
- 08-19-2011, 05:44 AM #7
Well, for someone that is "ignoring" me you certainly seem to not be.
As far as your last comment, and empty string and a null string are the same thing.
Empty string - Wikipedia, the free encyclopedia
Wait a sec, everyone else is wrong and junky is right.If you aren't programming in Java, well that's just too bad.
I'd rather be using Ubuntu.
- 08-19-2011, 05:47 AM #8
This message is hidden because stchman is on your ignore list.
View Post
Remove user from ignore list
This is what I see when logged on. Your posts are viewable when I am not logged on. Besides I have to monitor your posts to rectify all the incorrect information you post.
Of course I am.Wait a sec, everyone else is wrong and junky is right.
- 08-19-2011, 07:48 AM #9
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,543
- Rep Power
- 11
@stchman
The wikipedia page you linked to is worth reading. "The empty string is distinct from a null reference in that in an object-oriented programming language a null reference to a string type doesn't point to a string object and will cause an error were one to try to perform any operation on it"
It then goes on to list four characteristic properties of empty strings in many languages:
(1) It has length zero.
(2) It is the identity element of the free monoid on the alphabet
(3) It is its own reverse
(4) It precedes all other strings
Post code showing that any of these hold in Java for the string you produced in #4.
- 08-19-2011, 07:53 AM #10
Off the point. You're the only person here talking about a null String. Read the next line in that wikipedia article.
Correct.
------------------------------------------------------------------------------------
This statement of yours is completely wrong:
dbLast edited by DarrylBurke; 08-19-2011 at 10:51 AM. Reason: for clarity
- 08-19-2011, 07:58 AM #11
- 08-19-2011, 10:33 AM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
The only place I can think of offhand where an empty string is treated as NULL is Oracle, and boy does it cause pain there.
- 08-19-2011, 10:50 AM #13
- 08-22-2011, 10:36 AM #14
Member
- Join Date
- Mar 2011
- Posts
- 52
- Rep Power
- 0
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String.
Hi All,
This is My code:
Java Code:Workbook workbook = new Workbook(); workbook.open(filename); Worksheet worksheet = workbook.getWorksheets().getSheet(sheetno); Cells cells=worksheet.getCells(); int num=cells.getMaxDataRow(); int num1=cells.getMaxDataColumn(); int OCount=1; for (int n1=startpos+1;n1<endpos;n1++) { if (cells.checkCell(n1, Colno).getValue()==null ) { Cell cell=cells.getCell(n1,Colno); Style style = cells.getCell( n1,Colno).getStyle(); style.setColor(Color.TEAL); cell.setStyle(style); } else if(cells.checkCell(n1, Colno).getValue().toString().length()==0) { Cell cell=cells.getCell(n1,Colno); Style style = cells.getCell( n1,Colno).getStyle(); style.setColor(Color.TEAL); cell.setStyle(style); }else{ double intCounter = Double.parseDouble(cells.checkCell(n1,Colno).getValue().toString()); System.out.println(cells.checkCell(n1,Colno).getValue().toString()); if(intCounter!=Count) { Cell cell=cells.getCell(n1,Colno); Style style = cells.getCell( n1,Colno).getStyle(); style.setColor(Color.YELLOW); cell.setStyle(style); } } Count=Count+1; } workbook.save("C:\\output.xls",FileFormatType.EXCEL97TO2003);
I am trying to check that Sr no is in sequential order or not. it is working fine if there is no empty string " ". For empty string it throws
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: empty String.
Thanks in Advance....
- 08-22-2011, 11:50 AM #15
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
So, what do your requirements say about invalid (or empty) values in the cells then?
I don't see that anyone can deal with your "problem" until we know exactly what it is you're supposed to be doing.
- 08-22-2011, 12:09 PM #16
Member
- Join Date
- Mar 2011
- Posts
- 52
- Rep Power
- 0
Hi Tolls,
Thanks for your reply I am checking the sequential order in to my column. if the cell is containing Null value or Empty string it should highlight the cell with Color.TEAL. if number is not in sequence it should highlight the cell in yellow color.
- 08-22-2011, 01:02 PM #17
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
Exception in thread "main" java.lang.NumberFormatException:input string: "060320
By renu in forum New To JavaReplies: 14Last Post: 04-08-2011, 06:01 PM -
java.lang.NumberFormatException: For input string: ""
By chathura992 in forum New To JavaReplies: 3Last Post: 01-08-2011, 01:10 AM -
Exception in thread "main" java.lang.NumberFormatException: Value out of range. Value
By jav2000x in forum New To JavaReplies: 5Last Post: 04-12-2010, 03:39 PM -
jsp insert into database error(java.lang.NumberFormatException: For input string: "")
By cypher_girl in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 12-22-2009, 03:14 AM -
[newbie] Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException:
By jon80 in forum New To JavaReplies: 3Last Post: 06-07-2009, 12:14 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks