package water;
public class Fish
{
public static name = "Jerry" ;
}
##ReadMore##
file2
/* file2.java不在同一個package,程式碼的調用方法 */
public class PetScore
{
public static void main(String[] args)
{
String Name = water.Fish.name ;
}
}
file3
/* 調用import,類似C語言的include */
import water.*;
public class PetScore
{
public static void main(String[] args)
{
String Name = Fish.name ;
}
}
0 意見 :
張貼留言