為啥int定義過的不能在再添加int定義?
public?class?HelloWorld{ ????public?static?void?main(String[]?args)?{ ????int?one?=?10?; ????????int?two?=?20?; ????????int?three?=?0?; ????????three?=?one?+?two; ????????System.out.println("three?=?one?+?two?==>?"?+?three); ????????three?+=?one; ????????System.out.println("three?+=?one?==>?"?+?three); ????????three?-=?one; ????????System.out.println("three?-=?one?==>?"?+?three); ????????three?*=?one; ????????System.out.println("three?*=?one?==>?"?+?three); ????????three?/=?one; ????????System.out.println("three?/=?one?==>?"?+?three); ????????three?%=?one; ????????System.out.println("three?%=?one?==>?"?+?three); } }
我看了下問答,有人說three=one+two前面不用加上int,是因為前面已經(jīng)定義過了,不用打上去。
那我有個疑問,那為啥打上去int會報錯?看起來即時打上int也不會影響算法,那為什么會報錯?求各位指教。
2016-04-26
前面定義過了three不能重復(fù)定義