why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...

why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...

        public class d55 {
        int squares = 81;
        public static void main(String[] args) 
        {
            new d55().go();
    }
    void go() 
    {
        incr(++squares);
        System.out.println(squares);
    }

    int incr(int squares) 
    {
        return squares += 10; 

    }
}
View Answers

May 14, 2011 at 5:10 PM

There is a possibility of contradiction as you have declared a variable squares which is further declared as function parameter. So it is incrementing the value once by taking the class variable.

Use the given code:

     public class d55 {
        int squares = 81;
        public static void main(String[] args) 
        {
            new d55().go();
    }
    void go(){

       int num= incr(++squares);
        System.out.println(num);
    }

    int incr(int squares){

        int num=squares += 10;
        return num ; 
    }
}

May 15, 2011 at 10:44 AM

Thanks...









Related Tutorials/Questions & Answers:
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...   public class d55 { int squares = 81; public static void main(String
returning a value from Threads
returning a value from Threads  Hello I have worker pattern that uses ExecutorService to schedule Thread execution but getting stuck at some point when returning a value using Future.I have code snippet below: ExecutorService
Advertisements
method returning null on JSP page.Plz HELP!!!
to Java, so please help me as it could also because of some silly mistake. Thanks...method returning null on JSP page.Plz HELP!!!  public String... it is returning null while the parameter values are successfully passed.while I am
method returning null on JSP page.Plz HELP!!!
here. I am new to Java, so please help me as it could also because of some silly...method returning null on JSP page.Plz HELP!!!  public String... on the jsp page it is returning null while the parameter values are successfully
please please i wanna insertion sort program find calendar to array value (1000,5000,10000), please help me
Insertion sort program find calendar to array value 1000,5000,10000  program find calendar for insertion sort in jfram to array 1000
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me
autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me   Hi have develop the jsp to populate... filed?. Please help me Thanks
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT
please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4
Magic Squares - Java Beginners
or not. Please Help...Magic Squares  Magic Squares A magic square is an n by n grid containing the integers 1 to n2, which fulfils this condition: each of the sums
please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level stair case made of text. The user should choose the text character and the number of stairs in the stair case * ** *** ****   Hi friend
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4
Please help me fix this code - MobileApplications
Please help me fix this code   Please help me in this area of code... in the background of the forms in this code i want to sum all expenses amount... expenses)", "Please fill all required field \n \n * This signify required field
please help me to give code - Java Beginners
please help me to give code  Write a program that reads a file named famous.txt and prints out the line with the longest length. In the case of a tie, you may print out only one of them. For example in the file: Alan Turing
Please help me to modify my java code from php code
Please help me to modify my java code from php code  i want to covert...) ... but this is not giving me the exact result as the above PHP code is giving. So please... same, as they alter it before. Please help me on this topic "how to order rows
please help me
before. This name list should get from the database. Please help me. By the way, I'm...please help me  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another
Please help me to modify my java code from php code
]; } } I tried like this (see below JSP code) ... but this is not giving me the exact result as the above PHP code is giving. So please help me to convert...Modify Java code from PHP Code  i want to covert this php code int
please help me?
please help me?  Define a class named Circle with the following... constant named PI with a fixed value of 3.142 that represents the value of pi... radius value as the argument. A public method to display the Circle object
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
Please help me urgent...........
Please help me urgent...........  For what kind of a problem would... to the key value, then you have to use Tree Map. The Tree Map contains the data in a key-value pair and display the data in an unordered way. ThanksADS
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  Q 1) In a class first day 25 students are joined. After two days that total students will increased to 60. We can develop a program by using ArrayList concept
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please any one can help me to write a code for this question?
please any one can help me to write a code for this question?  1) Copy one file content to other? 2) Count the number of words in a file
this is my javascript code and i am not understanding the mistake in this,please help me?
this is my javascript code and i am not understanding the mistake in this,please help me?  <html> <h2>Form Validation</h2>...; if((nn1.value==null)||(nn1.value=="")){ alert("Please Enter
Please help me to write a code for add contacts to groups in a website?
Please help me to write a code for add contacts to groups in a website?   Iam developing a site. In that site I need to write code for Groups... send a code for this? Please make it fast
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
why set doesn't allow duplicate value
why set doesn't allow duplicate value  HI Everyone Any one can help me why set not allowed duplicate value in java. Please post ur comment, its urgent. Thanks in advance
Please help me out
Please help me out    Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track... a default value: the current year. Also be mindful of relevant, valid data types
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Please help me.
Please help me.  Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i not get it i.e; What is the work of "id".and what is the data type of id? http
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
help me please
help me please   Hello I want helping for this question , Please Write a program that reads some friendsââ?¬â?¢ names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
please help me.
please help me.  I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do
please help me...
please help me...  write an application that print number in the following order using a FOR-Loop 1 2 3 4 5 2 4 6 8 10 3 6 9 1215 4 8 121620 5 10152025
please help me in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard... inside the JTextField) but i want to make this program to let me write where i clicked (i.e allows me to write any thing at the field where i clicked
StringTokenizer not returning proper result
StringTokenizer not returning proper result  I have this code... System.out.print("Enter the stack integers side by side with a space in between...(st.hasMoreTokens()); When I print the elements in the array it prints me nothing
I need help on my Java code.... please please help me out!?
I need help on my Java code.... please please help me out!?  Well my code is supposed to ask for an input file and then (ex: input.txt), read... the anagram on screen or the output file! Please show me whats wrong. Thanks i
Please help me
Please help me  Hi Sir, please send me the code for the following progrems... 1) all sets are integer type: input: set1={10,20,30,40} set2={15,25,35} output: union={10,15,20,25,30,35,40} 2) input: "Hi what
help me please
help me please  how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
Please help me
Please help me  program for when a user enter his card number, it has to create default security pin in the database
please help me
please help me  interface Test1 { String toString(); } public class Test { public static void main(String[] args) { System.out.println(new Test1() { public String toString() { return "test
Please help me??
Please help me??  Question_1: Using one-dimension array of primitive type elements. Objective: The purpose of this lab exercise is to practice how to declare, create and manipulate a one-dimension array of primitive type
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
please help me to overcome this problem
please help me to overcome this problem  how to make it easy to write java code. can u please give me suggestions

Ads