• Post Reply Bookmark Topic Watch Topic
  • New Topic

sorting values in an array  RSS feed

 
vasantkr kr
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have split strings(multiple) in a string buffer into two parts(arr[0],arr[1]) and stored it in an array.How do i check if the string stored is a date or decimal or a word.
Can anyone give me the solution to it.
 
Scott Selikoff
author
Bartender
Posts: 4093
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean by reading a character one-by-one from buffer? You can try parsing, for example using Double.parseDouble() to determine if the string value is a decimal.
 
Adam Richards
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I read the previous post correctly, he is saying to rely on exceptions to detect data types. That would would work on a small scale, but will give performance problems on large systems. For the latter, a better approach is to parse the entries yourself & branch base on the data type you detect.
 
Harald Kirsch
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would "Thursday" be a date or a word. How about 20060130? Looks like a huge number to me, but could as well denote the 30th January 2006.

As you see there no way to prescribe a solution without a more detailed specification. But before posting the spec here, I suggest to have a look at regular expressions.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!