Java中参数的执行顺序保证? [英] Order of execution of parameters guarantees in Java?

查看:242
本文介绍了Java中参数的执行顺序保证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C 中给出以下函数调用:

Given the following function call in C:

fooFunc( barFunc(), bazFunc() );

执行顺序barFunc 未指定BazFunc ,因此可以在 bazFunc() barFunc() c $ c>或 bazFunc()之前 barFunc() in C

The order of execution of barFunc and BazFunc is not specified, so barFunc() may be called before bazFunc() or bazFunc() before barFunc() in C.

Java 指定函数参数表达式的执行顺序或类似 C 是未指定的?

Does Java specify an order of execution of function argument expressions or like C is that unspecified?

推荐答案

来自 Java语言规范(关于表达式):


15.7.4从左到右评估参数列表

15.7.4 Argument Lists are Evaluated Left-to-Right

在方法或构造函数调用
或类实例创建表达式中,
参数表达式可以出现在
括号内,用逗号分隔。
每个参数表达式在其右边任何
参数表达式的任何部分之前显示为
完全计算。

In a method or constructor invocation or class instance creation expression, argument expressions may appear within the parentheses, separated by commas. Each argument expression appears to be fully evaluated before any part of any argument expression to its right.

这篇关于Java中参数的执行顺序保证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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