


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



condition? expression1 : expression
1- 2
comparing floating point values for equality comparing characters comparing strings (alphabetical order) comparing object vs. comparing object references
if (Math.abs(f1 - f2) < TOLERANCE) System.out.println ("Essentially equal");
if (name1.compareTo(name2) < 0) System.out.println (name1 + "comes first"); else if (name1.compareTo(name2) == 0) System.out.println ("Same name"); else System.out.println (name2 + "comes first"); Lexicographic ordering is not strictly alphabetical when uppercase and lowercase characters are mixed For example, "Great" comes before the string "fantastic” Also, short strings come before longer strings with the same prefix Therefore "book" comes before "bookcase"
the hasNext method returns true if there is more data to be scanned the next method returns the next scanned token as a string
fileScan = new Scanner (new File("websites.inp")); // Read and process each line of the file while (fileScan.hasNext()) { url = fileScan.nextLine(); System.out.println ("URL: " + url); urlScan = new Scanner (url); urlScan.useDelimiter("/"); // Print each part of the url while (urlScan.hasNext()) System.out.println (" " + urlScan.next()); System.out.println(); } } }