wiki:jazz/09-07-07

Version 6 (modified by jazz, 15 years ago) (diff)

--

2009-07-07

  • 成大工科實習生
    • Part 1 : Java 多個類別的寫法
      // 存為 Test.java
      import java.io.*;
      import java.lang.String;
      
      public class Test
      {
        public String myData;
      
        public String getMyData()
        {
          return myData;
        }
      
        public void setMyData(String data)
        {
          myData = new String(data);
        }
      
        public static void main(String args[]) {
      	System.out.print("args.length=" + args.length);
      	System.out.print("\n");
      	if(args.length < 2)
      	{
      		System.out.print("Usgage: java Test myData myWeight");
      		System.exit(1);
      	}
          Test myTest = new Test();
      	myClass myclass = new myClass();
          myTest.setMyData(args[0]);
          System.out.print(myTest.getMyData());
      	System.out.print("\n");
      	System.out.print(myclass.getWeight());
      	System.out.print("\n");
      	myclass.setWeight(args[1]);
      	System.out.print(myclass.getWeight());
        }
      }
      
      public class myClass
      {
      	public String myWeight;
      	
      	public String getWeight()
      	{
      		return myWeight;
      	}
      	
      	public void setWeight(String weight)
      	{
      		myWeight = new String(weight);
      	}
      	
      	public myClass()
      	{
      		setWeight("50");
      	}
      	
      	public static void main(String args[]) {
      		myClass myclass = new myClass();
      		System.out.print(myclass.getWeight());
      	}
      }
      
  • Part 2 : Linux 安裝

Attachments (1)

Download all attachments as: .zip