Skip to content

Instantly share code, notes, and snippets.

View oscarryz's full-sized avatar

Oscar Reyes oscarryz

View GitHub Profile
abstract class A {
public String s() {
return this.getClass().getName();
}
}
class B extends A {
public static void main(String...args) {
System.out.println(B.class.getName());
System.out.println(new B().s());
}
{
"hash": "87b6c030d59c1c74357bb19a89d206517e09df2d"
}
import java.text.DecimalFormat;
class F {
public static void main( String ... args ) {
DecimalFormat f = new DecimalFormat("000,000.00");
double [] d = {
0.01,
0.12,
123456,
123456.78,
//A.java
class A {
private int i;
public String toString() { return ""+ i; }
}
// B.java
class B extends A {}
// Main.java
class Main {
public static void main( String [] args ) {
import java.util.function.BiConsumer;
import java.util.Arrays;
import java.util.List;
class SimpleClass {
void methodA(String a, String b) {
System.out.printf("%s %s%n", a, b);
}
}
@oscarryz
oscarryz / Main.java
Created September 24, 2013 16:39
Ultrasimplistic example of a mini/micro compiler that validates a sentence starting with "hombres" and finishing with "tal"
import java.text.ParseException;
class Lexer {
String [] tokens;
void tokenize( String input ) {
tokens = input.split("\\s");
}
}
class Parser {
void parse( String [] tokens ) throws ParseException {
// la regla es que empieze con "hombres" y termine con "tal"
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class Mano {
if ( apparentlyImportantValue);
doSomething();
validate : function( callback ) {
cancelTimeout( timeoutId );
timeoutId = setTimeout( callback, 2000 );
}