/
githubmirror
/
CS-Notes
Обзор
Документация
Войти
/
githubmirror
/
CS-Notes
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
docs/_style/prism-master/examples/prism-java.html
65 строк
1 KB
CyC2018
use prism-tomorrow.css
19 дек 2018, 09:09
19 дек 2018, 09:09
e9e604e
Код
Авторство
О чём код?
<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 < 10; r++) for(int c = 0; c < 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>