SCJP題庫第013題


1. public class Barn{
2.   public static void main(String[] args){
3.     new Barn.go("hi", 1);
4.     new Barn.go("hi", "world", 2);
5.   }
6.   public void go(String... y, int x){
7.     System.out.print(y[y.length-1] + " ");
8.   }
9. }
What is the result?
A. hi hi
B. hi world
C. world world
D. Compilation fails.
E. An exception is thrown at runtime

Ans:D

解說:
public void go(String... y, int x){
不定數量的參數必須寫在參數列的後面,上式需改為
public void go(int x , String... y){

Comments

參考投影片6/15-17頁

Popular posts from this blog

Android+Google Map API v3 Geocoding(地址轉經緯度度