Java表达式中的双引号是什么意思? [英] What do double quotes in a Java expression mean?

查看:483
本文介绍了Java表达式中的双引号是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有:

 2 + 2+ 3 + 4 

hello 34+ 2 * 4

有人可以解释这些表达式是如何评估的?

解决方案

将成为 String 。和 string + Int = String 。例如, / p>

 2 + 2+ 3 + 4 

您将在您的问题中获得 2 + 234



/ p>

 2 + 2+ 3 + 4 +hello 34+ 2 * 4 //我在' 4'和'hello',因为表达式中有错误

将被评估如下: p>

  1。 output =2 + 2+ 3 + 4 +hello 34+ 2 * 4 
2. output =2 + 2+ 3 + 4 +hello 34+ 8 // operation'*'先评估
3. output =2 + 23+ 4 +hello 34+ 8
4. output =2 + 234+hello 34+ 8
5。 output =2 + 234hello 34+ 8
6. output =2 + 234hello 348


What does double quotes mean in Java?

I have:

"2 + 2" + 3 + 4

"hello 34" + 2 * 4

Can someone explain how these expressions are evaluated?

解决方案

anything inside " " will become String. and string + Int = String .for example,

"2 + 2" + 3 + 4

you will get 2 + 234

in your question,

"2 + 2" + 3 + 4 +"hello 34" + 2 * 4 //i added '+' between '4' and 'hello' since there is an error in expression

will be evaluated like this:

1. output = "2 + 2" + 3 + 4 +"hello 34" + 2 * 4
2. output = "2 + 2" + 3 + 4 +"hello 34" + 8 //operation '*' evaluated first
3. output = "2 + 23" + 4 +"hello 34" + 8
4. output = "2 + 234" +"hello 34" + 8
5. output = "2 + 234hello 34" + 8
6. output = "2 + 234hello 348"

这篇关于Java表达式中的双引号是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆