Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: Assignment or Initialization? Date: Mon, 1 Feb 2016 20:57:33 -0500 Organization: Aioe.org NNTP Server Lines: 29 Message-ID: References: NNTP-Posting-Host: ANasIS7Js9OyLQwgloeBLQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:33559 On 2/1/2016 7:23 AM, Stefan Ram wrote: > In > > int i = 2; > i = 3; > > , there is an initialization and then an assignment. > > What about > > final int i; > i = 3; > > ? Is »i = 3« an assignment or an initialization or both? > > No, wait! I have looked up the JLS. It says that > »int i = 2;« is an assignment, too. > > »14.4.2 ... If a declarator has an initializer, the > initializer is evaluated and its value is assigned > to the variable.« ¯¯¯¯¯¯¯¯ Often studying JLS has little practical importance. But for a question like what some valid Java syntax is correctly called in Java then JLS is obviously the best source. Arne