for(null objectt c:s) System.out.println(n+++":"+c==null?"NULL":c.toString());字符串是怎么解析

 int x=4; System.out.println(“value is ” +((x&4)?99.9:9)); 输出是?_百度知道
 int x=4; System.out.println(“value is ” +((x&4)?99.9:9)); 输出是?
提问者采纳
99(x&gt:9)&#47,输出999;4;/如果x&gt?99;4).9
为什么是9.0呢?
(x&4)?99.9:9)相当于if(x&4)x=99.9elsex=9.0楼上说的对,编译了一下,因为9和99.9比较取值的,所以x自动转型为double型,否则x取不到99.9
提问者评价
其他类似问题
按默认排序
其他1条回答
因为整个表达式最高的是DOUBLE型,所以自动向上转型,显示9.0
((x&4)?99.9:9)); 这问号这种语法是什么意思?
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁以下程序段的输出结果是( )。 int a=15; System.out.println(~a); A:11 B:-21 C:-16 D:-15_百度知道
以下程序段的输出结果是( )。 int a=15; System.out.println(~a); A:11 B:-21 C:-16 D:-15
提问者采纳
好久没碰java没记错的话~a意思是反操作然后负数计算法则就是取反后+1所以(~a)=-(15+1)=-16结果是C
提问者评价
采纳率100%
其他类似问题
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁public class test {
public static void main(String[] args) {
int i =0 ;
for( i =0 ; i&=25; i++)
System.out.printf(&%d&, i);
(i%5==0)?System.out.println():System.out.print(& &);
output i want to generate:
0 1 2 3 4&
The message you get is not very clear. And neither is Oracle's&&statement
that ?: &can be thought of as shorthand for an if-then-else statement& because it is a little more limited.
From the JLS,&&&Note that it is a compile-time error
for either the second or the third operand expression to be an invocation of a void method.&&So the bpttom line is that if you want to conditionally evaluate one of two void methods, then you have to use if/else.
(A general point - which you should feel free to ignore for now - is that ?: will form an expression which always has a type. if/else on the other hand forms a statement that has no type associated with it.)
Well, they only need to be castable to the same type without loss if data, i.e. implicitly castable, which includes subclasses. But you can not write
? true : 1
? &hello& : 'w' //note that one of them is a String, and the other is a char (character).
And so on.
But why go into the complex when we are just describing the basics, implicitly castable is one of the things beginners usually have problems with.
And I think ?: is less OS dependent then +, which I believe is processor dependent and behaves exactly the same for all processors.
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:140062次
积分:2653
积分:2653
排名:第5728名
原创:125篇
转载:38篇
评论:12条
(1)(1)(2)(1)(5)(1)(3)(1)(2)(4)(6)(2)(5)(2)(1)(3)(1)(2)(1)(3)(1)(3)(1)(3)(7)(1)(1)(2)(15)(8)(1)(1)(4)(6)(17)(11)(13)(8)(5)(9)System.out.println(c=(a==b?a/b:b%a));谁详细的解释下:各代表什么?_百度作业帮
System.out.println(c=(a==b?a/b:b%a));谁详细的解释下:各代表什么?
a==b?a/b:b%a如果a==b成立,那么,运算结果为a/b,否则,为b%a然后,将运算结果赋给c然后,打印出cb:c是一个运算符,当a的值为真时,运算结果为b,当a的值为假时,运算结果为c
您可能关注的推广回答者:int x=4 ;system.out.println(((x&4)?99.99:9()); 为什么是9.0 不是9 谢谢_百度知道
int x=4 ;system.out.println(((x&4)?99.99:9()); 为什么是9.0 不是9 谢谢
提问者采纳
99.99为浮点型,运算时,整形会转换成比它级别高的类型
其他类似问题
按默认排序
其他2条回答
0了,当然是9,9也自动转换成浮点型了.99是浮点型数,在和9做运算的时候,在和浮点型做运算的时候自动转换成浮点型,int x = 4是短整型程序中99
9.0是浮点数。9是整数。
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁}

我要回帖

更多关于 null object 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信