• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using substring

 
Greenhorn
Posts: 25
Mac OS X Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 180
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic