效果输出: I'm apple! 77 I'm orange!
PHP版:
$apple="I'm apple!";
$orange="I'm orange!";
$number=77;
$link=$apple." ".$number." ".$orange;
echo $link;
JAVA版:
String apple="I'm apple!";
String orange="I'm orange!";
int number=77;
String link=apple+" "+number+" "+orange;
System.out.println(link);
Object-C版:
NSString *apple=@"I'm apple!";
NSString *orange=@"I'm orange!";
int number=77;
NSMutableString *link=[NSMutableString stringWithString:@""];
[link appendString:apple];
[link appendString:@" "];
[link appendString:[NSString stringWithFormat: @"%d", number]];
[link appendString:@" "];
[link appendString:orange];
NSLog(@"%@",link);
Swift版:( 注意数字的不支持隐式转换 )
let apple="I'm apple!"
let orange="I'm orange!"
let number=77
var link=apple+" "+String(number)+" "+orange
println(link)
以上几种语言你更喜欢哪种呢?