Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Splitting Java strings and extracting numbers

In Java you can use packages in the utility class to handle strings, or you can use methodsin java.lang.String which has been enhanced from version to version and now includes methods such as String.split().

Examples from today's course - taking a line of data (which could have been read from a file) and splitting it into elements which are then used to perform a calculation. [here].

That's a useful piece of code - but we've mixed up the logic of extracting the data and doing the calculation with the main program - not a good idea for the future extensibiity. So I refactored the example above - passing the string into a factory within a class to extract the data from it, and return me an object. I then ran a couple of methods on the object to do calculations that had been in the main code. Neat. Source [here].within a class to extract the data from it, and return me an object. I then ran a couple of methods on the object to do calculations that had been in the main code. Neat. Source [here].

Output ... in BOTH cases:

  trainee@kingston:~/2015$ java Station
  Swanseahas grown to a factor 1.5598733
  trainee@kingston:~/2015$


So we're seeing a growth in traffic at Swansea station from 2005 to 2013 of 55.9%
(written 2015-01-13, updated 2015-01-15)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
J707 - Java - Strings
  [4414] Java - converting an integer to a fixed length string - (2015-02-04)
  [3048] String handling - from first steps to practical examples - (2010-11-13)
  [2649] Length, size or capacity in Java? - (2010-02-24)
  [1557] Trying out our Java examples on our web site - (2008-02-27)
  [1446] An answer to a student asking 'Help' - (2007-11-27)


Back to
Interview conditions,and other instructions to staff
Previous and next
or
Horse's mouth home
Forward to
Philosophy behind object design - and how I applied in to a Java example
Some other Articles
TransWilts / Press and Publicity report for AGM / 30th January 2015
Java Utility class - flexible replacement for array. Also cacheing in objects and multiple catch clauses example.
Preparing data through a little bit of Perl
Philosophy behind object design - and how I applied in to a Java example
Splitting Java strings and extracting numbers
Interview conditions,and other instructions to staff
Refactoring Perl applications to give them a rosy future
Checking MySQL database backups have worked (not failed)
Cucumber example - test::unit, scenario outlines, datafile driven test
Global Regular Expression matching in Ruby (using scan)
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4393_Spl ... mbers.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat