Skip to content

Instantly share code, notes, and snippets.

@Tanner
Tanner / gist:1375475
Created November 18, 2011 03:12
CS 1331 Dynamic-Type Casts
public class Test {
public static void main(String[] args) {
Test test = new Test();
}
public Test() {
Corgi a = (Corgi)(new TeaCupCorgi()); // Compiles and Runs
Corgi b = (TeaCupCorgi)(new Corgi()); // Compiles, but doesn't Run
Corgi c = new Corgi(); // Compiles (this is the "new Corgi()" portion above on line 8)
@Tanner
Tanner / Test.java
Created October 14, 2011 20:12
JPanel with preferred size
import java.awt.*;
import javax.swing.*;
public class Test extends JPanel {
public Test() {
setPreferredSize(new Dimension(400, 400));
}
public static void main(String[] args) {
JFrame frame = new JFrame();