宣告物件變數
Objective-C: Baby *cuteBaby;
Java: Baby cuteBaby;
差異: 星字號
建立物件
Objective-C: Baby *cuteBaby = [[Baby alloc] initWithAge:3];
Java: Baby cuteBaby = new Baby(10);
for loop
Objective-C:
for(NSString *str in array)
Java:
for (String str : array)
array
Objective-C: NSMutableArray
NSMutableArray *array = [[NSMutableArray alloc] init];
array.count;
Java: ArrayList
ArrayList list = new ArrayList();
list.size();
dic
Objective-C: NSMutableDictionary
Java: HashMap
HashMap dic = new HaspMap();
dic.put("Peter", new Double(3434.34));
空物件
Objective-C: nil
Java: null
array使用
array裡物件的數量
Objective-C: array.count
Java: array.size()
沒有留言:
張貼留言