Java primitive declaratiron

Given the following code snippet:

int i = 0;

int y = + ++i;

System.out.println(y);

The result is 1. Why is this a valid declaration? Can anyone explain what is =+?

Answers


int y = + ++i;

The first + in this line is simply the unary + operator (see: Assignment, Arithmetic, and Unary Operators). It does nothing. It's similar to the unary - operator. The line above is equivalent to:

int y = ++i;

which increments i and then assigns the new value of i to y.


Need Your Help

Python: Sending large object over UDP

python sockets networking udp

I am new to socket programming and recently picked up Python for it. I have a few questions in mind which I can't seems to find a definite answer for.

How can I change cols of textarea in twitter-bootstrap?

ruby-on-rails-3 twitter-bootstrap

If I change the value of :rows, it works. But it stays at the default cols whatever value I set with ':cols =>'. Column width won't change.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.