标签:返回 能力 程序 size 支持 ati package 编程 import
package chapterFour; class OneClass { } //////////////////////// package chapterFour; interface OneInterface { } ///////////////////////// package chapterFour; class TestClass implements OneInterface { public static void main(String[] args) { OneClass one = new OneClass(); } }
package chapterFour; class TestClass { private interface OneInterface { } private class OneClass { } private OneInterface oneInterface = new OneInterface(){}; private OneClass oneClass = new OneClass(); }
package chapterFour; class OneClass { protected String protectedStr = "I am protected String"; } ////////////////////////////////////////////////////// package chapterFour; class ChidOneClass extends OneClass { public void visit(){ System.out.println(protectedStr); } } /////////////////////////////////////////////// package chapterFour; class Visiter { public void Visit() { OneClass one = new OneClass(); System.out.println(one.protectedStr); } }
private interface OneInterface { public int one = 10; public void method(); }
package chapterFour; public class OneClass { public static final String CAR_TYPE="HONDA"; //public static final OneInstance one; }
package chapterFour; class OneClass { //Potential security hole! public static final int[] VALUES = { 1, 2, 3 }; private static final float[] VALUES_FLOAT = {1.2f,1.3f}; //Potential security hole! public static float[] getFloatArray(){ return VALUES_FLOAT; } public static void main(String[] args){ OneClass.VALUES[0] = 10; OneClass .getFloatArray()[0] = 10.2f; } }
class OneClass { private static final int[] VALUES = { 1, 2, 3 }; private static final float[] VALUES_FLOAT = { 1.2f, 1.3f }; // method one ,return an unmodifiableList public static final List<int[]> values() { return Collections.unmodifiableList(Arrays.asList(VALUES)); } //method two ,return a copy of an array public static final float[] getFloatArray() { return VALUES_FLOAT.clone(); } } ///////////////////////////////////////////////////////////////////////////////////////// package chapterFour; import java.util.List; class TwoClass { public static void main(String[] args){ List<int[]> one = OneClass.values(); if(one.size() > 0){ int[] oneArray = one.get(0); for(int i = 0; i < oneArray.length; i++){ oneArray[i] = i*10; System.out.println(oneArray[i]); } } System.out.println("/////////////////////////////"); float[] oneFloat = OneClass.getFloatArray(); for(int i = 0; i < oneFloat.length; i++){ System.out.println(oneFloat[i]); } } }
标签:返回 能力 程序 size 支持 ati package 编程 import
原文地址:http://www.cnblogs.com/ttylinux/p/6623372.html