{"id":780,"date":"2013-04-01T14:35:55","date_gmt":"2013-04-01T03:35:55","guid":{"rendered":"http:\/\/www.rjmprogramming.com.au\/wordpress\/?p=780"},"modified":"2013-04-01T14:35:55","modified_gmt":"2013-04-01T03:35:55","slug":"java-arraylist-primer-tutorial","status":"publish","type":"post","link":"https:\/\/www.rjmprogramming.com.au\/ITblog\/java-arraylist-primer-tutorial\/","title":{"rendered":"Java ArrayList Primer Tutorial"},"content":{"rendered":"<div style=\"width: 230px\" class=\"wp-caption alignnone\"><a target=_blank href=\"http:\/\/www.rjmprogramming.com.au\/Java\/JavaArrayList\/\"><img decoding=\"async\" style=\"border: 15px solid pink;\" alt=\"Java XCode ArrayList Primer Tutorial\" src=\"http:\/\/www.rjmprogramming.com.au\/Java\/JavaArrayList\/JavaTool_XCode_Find_Occurrences-0of.jpg\" title=\"Java XCode ArrayList Primer Tutorial\"  style=\"float:left;\" \/><\/a><p class=\"wp-caption-text\">Java XCode ArrayList Primer Tutorial<\/p><\/div>\n<p>Here is a tutorial that uses ArrayList structure in Java via XCode on a Mac laptop.<\/p>\n<p>This program counts the occurrence of characters within the contents of a text file.<\/p>\n<p>We have one input text file which we are going to read.<br \/>\nWe use one ArrayList<string> to contain characters of interest to find.<br \/>\nWe use another ArrayList<integer> to contain character counts collected.<\/p>\n<p>Breaking this down, it would be good to:<\/p>\n<p>a) have method that reads the text file and does the report<br \/>\nb) have method to count occurrences of a character within a String<br \/>\nc) have method to count number of words within a String (and total characters in words)<\/p>\n<p>This way you can report:<\/p>\n<p>. occurrences of a character of interest within a line of the input text file<br \/>\n. total count and percentage of characters of interest within the whole text file<br \/>\n. total count and percentage of other characters within the whole text file<br \/>\n. total count of words within the whole text file<br \/>\n. average word size is ((total characters in words) \/ (total count of words))<\/p>\n<p>So we&#8217;ll build up a FindOccurrences class this way.<\/p>\n<p>Need to have rules about the input text file.   Will have it that:<\/p>\n<p>1) there is an optional first header record with number of records of interest<br \/>\n2) all records need {cr} (and\/or {lf}) delimitation (as a text file should)<\/p>\n<p>How do we obtain the filename?  Will have it that:<\/p>\n<p>(1) it can optionally be passed as a command line parameter<br \/>\n(2) if not we will prompt for it and allow a non-answer meaning it is inputfile.txt<\/p>\n<p>Do we assume a and A (for instance) are the same thing?   Will have it that:<\/p>\n<p>(a) assume as a default a and A are to be treated as one entity for searching purposes<br \/>\n(b) there is a, albeit awkward, way to say that a and A are separate, via (2) above<\/p>\n<p>Let&#8217;s see some  <a target=_blank title='click picture' href='http:\/\/www.rjmprogramming.com.au\/Java\/JavaArrayList\/'>Java<\/a> programming code for this, and how it works &#8230;\n<\/p>\n<p><a target=_blank href='http:\/\/www.rjmprogramming.com.au\/Java\/JavaArrayList\/FindOccurrences.java_GETME'>Download source code and rename to FindOccurrences.java<\/a><\/p>\n<p>If this was interesting you may be interested in <a title='Click here to see topics in which you might be interested' href='#d780' onclick='var dv=document.getElementById(\"d780\"); dv.innerHTML = \"&lt;iframe width=670 height=600 src=\" + \"http:\/\/www.rjmprogramming.com.au\/wordpress\/?s=ArrayList\" + \"&gt;&lt;\/iframe&gt;\"; dv.style.display = \"block\";'>this<\/a> too.<\/p>\n<div id='d780' style='display: none; border-left: 2px solid green; border-top: 2px solid green;'><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Here is a tutorial that uses ArrayList structure in Java via XCode on a Mac laptop. This program counts the occurrence of characters within the contents of a text file. We have one input text file which we are going &hellip; <a href=\"https:\/\/www.rjmprogramming.com.au\/ITblog\/java-arraylist-primer-tutorial\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,37,40],"tags":[104,644,997,1319,1473],"class_list":["post-780","post","type-post","status-publish","format-standard","hentry","category-elearning","category-tutorials","category-xcode","tag-arraylist","tag-java","tag-programming","tag-tutorial","tag-xcode"],"_links":{"self":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/780"}],"collection":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/comments?post=780"}],"version-history":[{"count":0,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/posts\/780\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/media?parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/categories?post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rjmprogramming.com.au\/ITblog\/wp-json\/wp\/v2\/tags?post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}