Java Cheatsheet

Download Java Cheatsheet

Post on 24-Oct-2014

66 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

<p>Visit: ProgrammingKid.com</p> <p>Java Programming Cheat SheetHello, World.</p> <p>Editing, compiling, and executing.</p> <p>Built-in data types.</p> <p>Courtesy : Robert Sedgewick and Kevin Wayne. Copyright 2007. All rights reserved</p> <p>Visit: ProgrammingKid.com</p> <p>Declaration and assignment statements.</p> <p>Integers.</p> <p>Courtesy : Robert Sedgewick and Kevin Wayne. Copyright 2007. All rights reserved</p> <p>Visit: ProgrammingKid.com</p> <p>Floating point numbers.</p> <p>Booleans.</p> <p>Courtesy : Robert Sedgewick and Kevin Wayne. Copyright 2007. All rights reserved</p> <p>Visit: ProgrammingKid.com</p> <p>Comparison operators.</p> <p>Math library.</p> <p>Command-line arguments.</p> <p>Courtesy : Robert Sedgewick and Kevin Wayne. Copyright 2007. All rights reserved</p> <p>Visit: ProgrammingKid.com int a = Integer.parseInt(args[0]); double b = Double.parseDouble(args[1]); String c = args[2]; // read int from command-line // read double from command-line // read String from command-line</p> <p>Type conversion.</p> <p>If and if-else statements.</p> <p>Courtesy : Robert Sedgewick and Kevin Wayne. Copyright 2007. All rights reserved</p> <p>Visit: ProgrammingKid.com</p> <p>Nested if-else statement.</p> <p>While and for loops.</p> <p>Nested for loops. If-else nested inside a while loop.// how many fair bets until you go broke? int bets = 0; while (stake &gt; 0) { bets++; if (Math.random() &lt; 0.5) stake++; else stake--; }</p> <p>Courtesy : Robert Sedgewick and Kevin Wayne. Copyright 2007. All rights reserved</p> <p>Visit: ProgrammingKid.com</p> <p>Deeper nesting.// print out Pythagorean triples (i, j, k) such that i^2 + j^2 = k^2 for (int i = 1; i</p>