alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Java example source code file (RefTypes.java)

This example Java source code file (RefTypes.java) is included in the alvinalexander.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Learn more about this Java project at its project page.

Java - Java tags/keywords

abstract, abstractandnative, allabstract, allnative, classnotfoundexception, interfacewithcode, reftypes, string

The RefTypes.java Java example source code

/* /nodynamiccopyright/ hard coded linenumbers in other tests - DO NOT CHANGE
 * Debuggee which exercises various reference types
 */

abstract class AllAbstract {
    abstract void a();
    abstract void b();
    abstract void c();
}

class AllNative {
    native void a();
    native void b();
    native void c();
}

abstract class Abstract {
    abstract void a();
    void b() {
        int x = 1;
        int y = 2;
        System.out.println("x + y = " + x + y);
        return;
    }
}

class Native {
    native void a();
    void b() {
        int x = 1;
        int y = 2;
        System.out.println("x + y = " + x + y);
        return;
    }
}

abstract class AbstractAndNative {
    abstract void a();
    native void b();
    void c() {
        int x = 1;
        int y = 2;
        System.out.println("x + y = " + x + y);
        return;
    }
}

interface Interface {
    void a();
    void b();
    void c();
}

interface InterfaceWithCode {
    String foo = new String("foo");
}

public class RefTypes {
    static void loadClasses() throws ClassNotFoundException {
        Class.forName("AllAbstract");
        Class.forName("AllNative");
        Class.forName("Abstract");
        Class.forName("Native");
        Class.forName("AbstractAndNative");
        Class.forName("Interface");
        Class.forName("InterfaceWithCode");
    }

    public static void main(String args[]) throws Exception {
        loadClasses();
    }
}

Other Java examples (source code examples)

Here is a short list of links related to this Java RefTypes.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.