






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!







public class fahr { public static void main(String[] args){ for (int fahr = 0; fahr < 300; fahr += 20) System.out.println(fahr + " " + 5.0 * (fahr - 32) / 9.0); } }
public class echo { public static void main(String[] args) { for (int i = 0; i < args.length; i++) if (i < args.length-1) System.out.print(args[i] + " "); else System.out.println(args[i]); } }
public class echo1 { public static void main(String[] args) { String s = ""; for (int i = 0; i < args.length-1; i++) s += args[i] + " "; if (args.length > 0) s += args[args.length-1]; if (s != "") System.out.println(s); } }
public RE(String re) { this.re = re;
}
RE r; r = new RE(s);
public RE() { / ??? / }
public class RE { static int num_REs = 0;
public RE(String re) { num_REs++; ... }
class RE {
private variables public RE methods, including constructor(s) private functions
public static void main(String[] args) { extract re for (i = 1; i < args.length; i++) fin = open up the file... grep(re, fin) } static int grep(String regexp, FileReader fin) { RE re = new RE(regexp); for each line of fin if (re.match(line)) ... } }
public class cat3 {
public static void main(String[] args) { BufferedReader in = new BufferedReader( new InputStreamReader(System.in)); BufferedWriter out = new BufferedWriter( new OutputStreamWriter(System.out)); try { String s; while ((s = in.readLine()) != null) { out.write(s); out.newLine(); } out.flush(); // required!!! } catch (Exception e) { System.err.println("IOException " + e); } }
public void foo() { try { // if anything here throws an IO exception // or a subclass, like FileNotFoundException } catch (IOException e) { // this code will be executed // to deal with it }
public void foo() throws IOException { // if anything here throws an exception // foo will throw an exception // to be handled by its caller }
public static void main(String args[]) throws IOException { int b; while ((b = System.in.read()) >= 0) System.out.write(b); }