<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Increament operator error' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Increament operator error' posted on the 'Java' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Thu, 20 Jun 2013 01:10:57 -0700</pubDate>
    <lastBuildDate>Thu, 20 Jun 2013 01:10:57 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Increament operator error</title>
      <link>http://www.programmersheaven.com/mb/java/429253/429253/increament-operator-error/</link>
      <description>i started learning JAVA a few days back.&lt;br /&gt;
i thought of writing my first program on arithmetic operators.&lt;br /&gt;
but i m getting compilation error with the "++" operator.&lt;br /&gt;
below is my code.&lt;br /&gt;
&lt;pre class="sourcecode"&gt;public class IntArithmeticOperations {
       public static void main(String args[]){
	 System.out.println("Arithmetic Operations Sample");
	 
	 int i=10;
	 
	 int increamentResult=++i;//This is ok
	 int increamentResult1=++(i);//This is also ok
	 int increamentResult2=doit(++i);  //This is also ok
	 int increamentResult3=++(++i);   //This gives a compilation
error
	 int increamentResult4=++(i=i++); //This gives a compilation error
	 int increamentResult5=++(i+1); //This gives a compilation error
	 
	 System.out.println("IncreamentResult is"+increamentResult);
	 System.out.println("IncreamentResult1 is"+increamentResult1);
	 System.out.println("IncreamentResult2 is"+increamentResult2);
	 System.out.println("IncreamentResult3 is"+increamentResult3);
	 System.out.println("IncreamentResult4 is"+increamentResult4);
	 System.out.println("IncreamentResult5 is"+increamentResult5);
    }
 public static int doit(int i){
	 return i;
 }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Please help me understand how the "++" operator works.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/429253/429253/increament-operator-error/</guid>
      <pubDate>Sat, 18 Aug 2012 02:16:12 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Increament operator error</title>
      <link>http://www.programmersheaven.com/mb/java/429253/429298/re-increament-operator-error/#429298</link>
      <description>public class IntArithmeticOperations {&lt;br /&gt;
       public static void main(String args[]){&lt;br /&gt;
	 System.out.println("Arithmetic Operations Sample");&lt;br /&gt;
	 &lt;br /&gt;
	 int i=10; You have initialized the code which is good&lt;br /&gt;
	 &lt;br /&gt;
	 int increamentResult=++i;//This is ok&lt;br /&gt;
this is saying add 1 which increments the value i to 11&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult1=++(i);//This is also ok&lt;br /&gt;
the brackets doesn't matter in this one its the same as before but you're adding 1 again which makes the value 12&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult2=doit(++i);  //This is also ok&lt;br /&gt;
this is calling the doit method (which just goes down to see if there's anything in the method doit. You've only returned i so it comes back to this statement and increments it...so now its 13.&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult3=++(++i);   //This gives a compilation&lt;br /&gt;
error&lt;br /&gt;
&lt;br /&gt;
this is causing an error because it wants a variable. You're not calling any methods and you can't just put ++ and (++i). make these statements in different lines &lt;br /&gt;
e.g &lt;br /&gt;
int increamentResult3=i++;&lt;br /&gt;
int incrementResult4 = doits(++i);&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult4=++(i=i++); //This gives a compilation error&lt;br /&gt;
int increamentResult5=i++;&lt;br /&gt;
&lt;br /&gt;
//make another method &lt;br /&gt;
&lt;br /&gt;
int incrementResult5 = doits(i=i++);&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult5=++(i+1); //This gives a compilation error&lt;br /&gt;
	 &lt;br /&gt;
	 System.out.println("IncreamentResult is"+increamentResult);&lt;br /&gt;
	 System.out.println("IncreamentResult1 is"+increamentResult1);&lt;br /&gt;
	 System.out.println("IncreamentResult2 is"+increamentResult2);&lt;br /&gt;
	 System.out.println("IncreamentResult3 is"+increamentResult3);&lt;br /&gt;
	 System.out.println("IncreamentResult4 is"+increamentResult4);&lt;br /&gt;
	 System.out.println("IncreamentResult5 is"+increamentResult5);&lt;br /&gt;
    }&lt;br /&gt;
 public static int doit(int i){&lt;br /&gt;
	 return i;&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
hope i didn't confuse you too much :) i'm new to java too</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/429253/429298/re-increament-operator-error/#429298</guid>
      <pubDate>Thu, 23 Aug 2012 02:55:58 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Increament operator error</title>
      <link>http://www.programmersheaven.com/mb/java/429253/429299/re-increament-operator-error/#429299</link>
      <description>public class IntArithmeticOperations {&lt;br /&gt;
       public static void main(String args[]){&lt;br /&gt;
	 System.out.println("Arithmetic Operations Sample");&lt;br /&gt;
	 &lt;br /&gt;
	 int i=10; You have initialized the code which is good&lt;br /&gt;
	 &lt;br /&gt;
	 int increamentResult=++i;//This is ok&lt;br /&gt;
this is saying add 1 which increments the value i to 11&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult1=++(i);//This is also ok&lt;br /&gt;
the brackets doesn't matter in this one its the same as before but you're adding 1 again which makes the value 12&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult2=doit(++i);  //This is also ok&lt;br /&gt;
this is calling the doit method (which just goes down to see if there's anything in the method doit. You've only returned i so it comes back to this statement and increments it...so now its 13.&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult3=++(++i);   //This gives a compilation&lt;br /&gt;
error&lt;br /&gt;
&lt;br /&gt;
this is causing an error because it wants a variable. You're not calling any methods and you can't just put ++ and (++i). make these statements in different lines &lt;br /&gt;
e.g &lt;br /&gt;
int increamentResult3=i++;&lt;br /&gt;
int incrementResult4 = doits(++i);&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult4=++(i=i++); //This gives a compilation error&lt;br /&gt;
int increamentResult5=i++;&lt;br /&gt;
&lt;br /&gt;
//make another method &lt;br /&gt;
&lt;br /&gt;
int incrementResult5 = doits(i=i++);&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult5=++(i+1); //This gives a compilation error&lt;br /&gt;
	 &lt;br /&gt;
	 System.out.println("IncreamentResult is"+increamentResult);&lt;br /&gt;
	 System.out.println("IncreamentResult1 is"+increamentResult1);&lt;br /&gt;
	 System.out.println("IncreamentResult2 is"+increamentResult2);&lt;br /&gt;
	 System.out.println("IncreamentResult3 is"+increamentResult3);&lt;br /&gt;
	 System.out.println("IncreamentResult4 is"+increamentResult4);&lt;br /&gt;
	 System.out.println("IncreamentResult5 is"+increamentResult5);&lt;br /&gt;
    }&lt;br /&gt;
 public static int doit(int i){&lt;br /&gt;
	 return i;&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
hope i didn't confuse you too much :) i'm new to java too</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/429253/429299/re-increament-operator-error/#429299</guid>
      <pubDate>Thu, 23 Aug 2012 02:58:16 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re: Increament operator error</title>
      <link>http://www.programmersheaven.com/mb/java/429253/429300/re-increament-operator-error/#429300</link>
      <description>public class IntArithmeticOperations {&lt;br /&gt;
       public static void main(String args[]){&lt;br /&gt;
	 System.out.println("Arithmetic Operations Sample");&lt;br /&gt;
	 &lt;br /&gt;
	 int i=10; You have initialized the code which is good&lt;br /&gt;
	 &lt;br /&gt;
	 int increamentResult=++i;//This is ok&lt;br /&gt;
this is saying add 1 which increments the value i to 11&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult1=++(i);//This is also ok&lt;br /&gt;
the brackets doesn't matter in this one its the same as before but you're adding 1 again which makes the value 12&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult2=doit(++i);  //This is also ok&lt;br /&gt;
this is calling the doit method (which just goes down to see if there's anything in the method doit. You've only returned i so it comes back to this statement and increments it...so now its 13.&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult3=++(++i);   //This gives a compilation&lt;br /&gt;
error&lt;br /&gt;
&lt;br /&gt;
this is causing an error because it wants a variable. You're not calling any methods and you can't just put ++ and (++i). make these statements in different lines &lt;br /&gt;
e.g &lt;br /&gt;
int increamentResult3=i++;&lt;br /&gt;
int incrementResult4 = doits(++i);&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult4=++(i=i++); //This gives a compilation error&lt;br /&gt;
int increamentResult5=i++;&lt;br /&gt;
&lt;br /&gt;
//make another method &lt;br /&gt;
&lt;br /&gt;
int incrementResult5 = doits(i=i++);&lt;br /&gt;
&lt;br /&gt;
	 int increamentResult5=++(i+1); //This gives a compilation error&lt;br /&gt;
	 &lt;br /&gt;
	 System.out.println("IncreamentResult is"+increamentResult);&lt;br /&gt;
	 System.out.println("IncreamentResult1 is"+increamentResult1);&lt;br /&gt;
	 System.out.println("IncreamentResult2 is"+increamentResult2);&lt;br /&gt;
	 System.out.println("IncreamentResult3 is"+increamentResult3);&lt;br /&gt;
	 System.out.println("IncreamentResult4 is"+increamentResult4);&lt;br /&gt;
	 System.out.println("IncreamentResult5 is"+increamentResult5);&lt;br /&gt;
    }&lt;br /&gt;
 public static int doit(int i){&lt;br /&gt;
	 return i;&lt;br /&gt;
 }&lt;br /&gt;
}&lt;br /&gt;
hope i didn't confuse you too much :) i'm new to java too &lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/429253/429300/re-increament-operator-error/#429300</guid>
      <pubDate>Thu, 23 Aug 2012 03:00:07 -0700</pubDate>
      <category>Java</category>
    </item>
  </channel>
</rss>