• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using substring  RSS feed

 
Martin Bluck
Greenhorn
Posts: 25
Chrome Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to use the substring function to access a specific part of a string.

I can use it like this to access the temperature at the end.

Which gives me 31.7

But I'd like to know if there's a way that I can access 45.6 only?
 
Salil Wadnerkar
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could have saved time by googling the substring API:
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looking at the line data, there are 3 possible data values: "#2014/01/01", "45.6C" and "31.7". Do you see what separates them?

Are all 3 values relevant?

Substring isn't a good approach in such situation. Have a more closer look at the String API. Hint array return type.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!