2013年1月28日 星期一

Java 學習筆記~2維陣列變數


class Data
{
    // 宣告x2維陣列
    private  static int x[][]=new int[2][];
    private static double  w[]=new double [2];
    public static void setX(int[][] aX) { x = aX; }
    public static int[][] getX() {  return x;    }   
    public static double[] getW() {return w; }
    public static void setW(double[] aW) {w = aW;   }   
   
}
public class preceptron {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         //x 為一4x2 陣列
        int x[][]={{0,0},{0,1},{1,0},{1,1}};    
        double w[][]={{0.5,0.5}};      
        int i,j;       
        Data.setX(x);
        for (i=0;i<4;i++)
        {
             for (j=0;j<2;j++)  
                 System.out.print(Data.getX()[i][j]);
                 System.out.println();
        }

   /* Data.setW(w[0]);
    for (j=0;j<2;j++)
    System.out.println(Data.getW()[j]);    */
    }

}

沒有留言:

張貼留言