Debian Codegraph @

examples/prism-java.html

raw symbols SCIP
1 <h2>Comments</h2>
2 <pre><code>// Single line comment
3 /* Multi-line
4 comment */</code></pre>
5
6 <h2>Strings</h2>
7 <pre><code>"foo \"bar\" baz";
8 'foo \'bar\' baz';</code></pre>
9
10 <h2>Numbers</h2>
11 <pre><code>123
12 123.456
13 -123.456
14 .3f
15 1.3e9d
16 0xaf
17 0xAF
18 0xFF.AEP-4
19 </code></pre>
20
21 <h2>Full example</h2>
22 <pre><code>import java.util.Scanner;
23
24 public class Life {
25
26 @Override @Bind("One")
27 public void show(boolean[][] grid){
28 String s = "";
29 for(boolean[] row : grid){
30 for(boolean val : row)
31 if(val)
32 s += "*";
33 else
34 s += ".";
35 s += "\n";
36 }
37 System.out.println(s);
38 }
39
40 public static boolean[][] gen(){
41 boolean[][] grid = new boolean[10][10];
42 for(int r = 0; r &lt; 10; r++)
43 for(int c = 0; c &lt; 10; c++)
44 if( Math.random() > 0.7 )
45 grid[r][c] = true;
46 return grid;
47 }
48
49 public static void main(String[] args){
50 boolean[][] world = gen();
51 show(world);
52 System.out.println();
53 world = nextGen(world);
54 show(world);
55 Scanner s = new Scanner(System.in);
56 while(s.nextLine().length() == 0){
57 System.out.println();
58 world = nextGen(world);
59 show(world);
60
61 }
62 }
63
64 // [...]
65 }</code></pre>