File: prism-java.html

package info (click to toggle)
node-prismjs 1.30.0%2Bdfsg%2B~1.26.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,220 kB
  • sloc: javascript: 27,628; makefile: 9; sh: 7; awk: 4
file content (65 lines) | stat: -rw-r--r-- 1,368 bytes parent folder | download | duplicates (3)
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
<h2>Comments</h2>
<pre><code>// Single line comment
/* Multi-line
comment */</code></pre>

<h2>Strings</h2>
<pre><code>"foo \"bar\" baz";
'foo \'bar\' baz';</code></pre>

<h2>Numbers</h2>
<pre><code>123
123.456
-123.456
.3f
1.3e9d
0xaf
0xAF
0xFF.AEP-4
</code></pre>

<h2>Full example</h2>
<pre><code>import java.util.Scanner;

public class Life {

    @Override @Bind("One")
    public void show(boolean[][] grid){
        String s = "";
        for(boolean[] row : grid){
            for(boolean val : row)
                if(val)
                    s += "*";
                else
                    s += ".";
            s += "\n";
        }
        System.out.println(s);
    }

    public static boolean[][] gen(){
        boolean[][] grid = new boolean[10][10];
        for(int r = 0; r &lt; 10; r++)
            for(int c = 0; c &lt; 10; c++)
                if( Math.random() > 0.7 )
                    grid[r][c] = true;
        return grid;
    }

    public static void main(String[] args){
        boolean[][] world = gen();
        show(world);
        System.out.println();
        world = nextGen(world);
        show(world);
        Scanner s = new Scanner(System.in);
        while(s.nextLine().length() == 0){
            System.out.println();
            world = nextGen(world);
            show(world);

        }
    }

	// [...]
}</code></pre>