• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

problem with method

Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone, my name is Erik. i am new to Java. I am confused by this methods here can anyone briefly explain every steps to me except for line 1 & 2 thank you.

public class DemoRaise {
public static void main(String[] args) {
double mySalary = 200.00;
System.out.println("Demonstrating some raises");
public static void predictRaise (double moneyAmount) { // why does moneyAmount is in the paranthesis? Can i just declare the moneyAmount variable same as how i declare the newAmount?
double newAmount;
newAmount = moneyAmount * 1.10;
System.out.println("With raise salary is " + newAmount);


The result for this method:
The result for this method click here
[ February 28, 2004: Message edited by: ayukawa madoka ]
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Erik, Welcome to JavaRanch...
What�s happening in these two lines:

is that the program is calling the method �predictRaise� which takes a double as a parameter. This is indicated in the signature of the predictRaise() method:

The moneyAmount in the parenthesis is the variable the method uses to hold the parameter it receives.
The predictRaise() method then makes a calculation (newAmount = moneyAmount * 1.10; ) on the value it received as a parameter (�moneyAmount�) and displays the results via a call to System.out.println()
At a very high-level, that is what is happening. Anything beyond that is a bit too much to get into via a forum like this, and is the core concepts to Object Oriented Programming and the Java Language. I suggest you read through some Beginning Java tutorials such as Sun�s The Java Tutorial or the electronic book Thinking in Java. There is also the online tutorial Introduction to Computer Science using Java. You can also look at purchasing the excellent book Head First Java. Any of these resources, or the many other Intro to Java Books out there (see this recent thread for some other suggestions), will explain what methods are, what they are used for, and what their parameters are and do.
Ayukawa Madoka
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh that means i can reuse the method over and over again with a different value passed in. Yay thanks for the brief explanation and the tutorial links everyone!
    Bookmark Topic Watch Topic
  • New Topic