Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


VS
why above code returning the value of squares is 82... even after returning an increnented value of squares... please help me...
2 Answer(s)      3 years and 4 months ago
Posted in : Java Beginners


        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; 

    }
}

Advertisement
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
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 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
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
Find sum of the squares of Array elements
' that will display the sum of the squares of Array elements. Here is the code...Find sum of the squares of Array elements In this section, you will learn how to compute the sum of the squares of the array elements. For this, we have
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 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 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
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 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 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 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
returning doubles with 2 decimals JAVA
but I need it to return a double. Help please...returning doubles with 2 decimals JAVA  Hi all. I'm writing a program where users input the cost of an item (in the constructor), so for example
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 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
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.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
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 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 urgent...........
Please help me urgent...........  For what kind of a problem would use a Tree Set and not a Tree Map For what kind of a problem would use a Tree Map... value, then you have to use Tree Map. The Tree Map contains the data in a key-value
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 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
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 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
Advertisements
 

 

 

DMCA.com