Skip to content

Instantly share code, notes, and snippets.

@isurum
isurum / RandomCharacter.java
Created March 23, 2017 16:24
A random integer between (int)'a' and (int)'z' is, (int)((int)'a' + Math.random() * ((int)'z' - (int)'a' + 1). every character has a unique Unicode between 0 and FFFF in hexadecimal (65535 in decimal). To generate a random character is to generate a random integer between 0 and 65535 using the following expression (note that since 0 <= Math.rand…
package learnjava.general;
/**
* Created by Isuru on 23/03/2017.
*/
public class RandomCharacter {
/** Generates random character */
public static char getRandomCharacter(char ch1, char ch2){
return (char) (ch1 + Math.random() * (ch2 - ch1 + 1));
@isurum
isurum / SentinelValueUsingConfirmationDialog.java
Last active March 23, 2017 12:27
A program displays an input dialog to prompt the user to enter an integer (line 11) and adds it to sum (line 15). Line 17 displays a confirmation dialog to let the user decide whether to continue the input. If the user clicks Yes, the loop continues; otherwise the loop exits. Finally, the program displays the result in a message dialog box (line…
package learnjava.testing;
import javax.swing.*;
/**
* Created by Isuru on 20/03/2017.
*/
public class Main {
public static void main(String args[]){
@isurum
isurum / pattern.java
Created March 20, 2017 15:56
Introduction to Java Programming 8th Edition
package learnjava.testing;
/**
* Created by Isuru on 20/03/2017.
*/
public class Main {
public static void main(String args[]){
System.out.println(" J A V V A");
System.out.println(" J A A V V A A");
System.out.println("J J AAAAA VV AAAAA");
@isurum
isurum / 0_reuse_code.js
Created July 2, 2014 19:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console