*
The moose likes Beginning Java and the fly likes method call Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "method call" Watch "method call" New topic
Author

method call

catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
what is the difference between function call and a procedure call?
The function returns a value and the procedure doesnt?

When i send a value to a method.... After it does the procedures specified... will it come back to the origin...... For examply

if (x==y)
{
//some workings
methodcall(x)
}
if// second if
{
methodcall(x)
}
public void methodcall(int m)

{
//some functions
}

well... once the methodcall is invoked and after it finishes the functions does it goes back to the second if statement? I tried it.... it doesnt...
so what do i do get the second if working ?

[ June 10, 2006: Message edited by: catherine matthews ]
[ June 10, 2006: Message edited by: laxmi ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

laxmi,

Your name does not conform with our naming policy. You appear to have had a valid name in the past, but have changed it.

You must have a real sounding first and last name, separated by a space.

Please read this and then go here and change your name.

thanks


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78
well... its an indian name.... My name at home... Laxmi... nevermind i changed it anyway....
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

laxmi is fine - i wasn't questioning that. Catherine is fine. whichever you prefer. However,

All JavaRanch users are asked to use a real name as their display name, with a first and last name, and maybe more, separated by spaces.


so, you can use either, but you must have a last name as well.
Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
Hi Laxmi,

welcome to the ranch.

Now, there's no difference between a function call or a procedure call.
They are both "functions" that belong to an object. In Java we call functions
and procedures for methods. You might say, that the methods are the
services that the object provide to its clients/environment.

What happends in the small example you provide is the following:
1. evaluate if x equals y, if this is the case the method "methodcall"
is invoked.
2. Execute methodcall, then return.
3. evaluate second if statement, if it evaluates to true the method
methodcall will be invoked for the second time.

If the method doesn't return after the method call, there might be
an error of some sort in the method or in the code right after/before
the method call.

Try the following:


/Svend Rost

edit: removed the "please change your name according to the naming policy"
note I had in my first post.
[ June 10, 2006: Message edited by: Svend Rost ]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11150
    
  16

now, to your question... i'm not sure the technical difference between a "function" and a "procedure". Java only has "methods". i think that different languages (fortran, pascal, C, etc) used different terms for what is BASICALLY all the same thing. So, in Java, it is a method whether it returns a value or not.

after a method is called, you go back to the line immediatly after the method call. so yes, you should go back to the second if.

why do you think it's not? you're example doesn't have a valid if (there's no condition in it), but i assume that's just an oversite in whipping up this example? can you post your real code?

note that it would also help if you used the "code" tags. after you paste/type in your code, highlight it and click the "code" button you see below, in that "Instant UBB Code" section. it will then preserve your formatting, making it easier to read.
catherine matthews
Ranch Hand

Joined: Jan 22, 2006
Posts: 78


I have a few more if else statements.... all the if statements would call the same method thebraces()....as following


My codes are simply too long.... My ouput is
the words are 0 ========public
the words are 1 ========class
the words are 2 ========AccountRecord
the words are 3 ========private
the words are 4 ========int
the words are 5 ========account;
the words are 6 ========private
the words are 7 ========String
the words are 8 ========firstName;
the words are 9 ========private
the words are 10 ========String
the words are 11 ========lastName;
the words are 12 ========private
the words are 13 ========double
the words are 14 ========balance;//
the words are 15 ========the
the words are 16 ========defoult
the words are 17 ========constructor
the words are 18 ========public
the words are 19 ========AccountRecord()
the words are 20 ========{
the words are 21 ========this
the words are 22 ========(
the words are 23 ========0,"",
the words are 24 ========"",
the words are 25 ========0.0);
the words are 26 ========}
the words are 27 ========AccountRecord
the words are 28 ========(int
the words are 29 ========acct,
the words are 30 ========String
the words are 31 ========first,
the words are 32 ========String
the words are 33 ========last,
the words are 34 ========double
the words are 35 ========bal)
the words are 36 ========{
the words are 37 ========setAccount
the words are 38 ========(acct);
the words are 39 ========setFirstName
the words are 40 ========(first);
the words are 41 ========setLastName
the words are 42 ========(last);
the words are 43 ========setBalance
the words are 44 ========(bal);
the words are 45 ========}//
the words are 46 ========the
the words are 47 ========variable
the words are 48 ========constructor
the words are 49 ========public
the words are 50 ========void
the words are 51 ========setAccount
the words are 52 ========(int
the words are 53 ========acct)
the words are 54 ========{
the words are 55 ========account
the words are 56 =========acct;
the words are 57 ========}
the words are 58 ========public
the words are 59 ========int
the words are 60 ========getAccount(
the words are 61 ========)
the words are 62 ========{
the words are 63 ========return
the words are 64 ========account;
the words are 65 ========}
the words are 66 ========public
the words are 67 ========void
the words are 68 ========setFirstName(
the words are 69 ========String
the words are 70 ========first)
the words are 71 ========{
the words are 72 ========firstName
the words are 73 =========
the words are 74 ========first;
the words are 75 ========}
the words are 76 ========String
the words are 77 ========getFirstName()
the words are 78 ========{
the words are 79 ========return
the words are 80 ========firstName;
the words are 81 ========}
the words are 82 ========public
the words are 83 ========void
the words are 84 ========setLastName(
the words are 85 ========String
the words are 86 ========last)
the words are 87 ========{
the words are 88 ========lastName=
the words are 89 ========last;
the words are 90 ========}
the words are 91 ========public
the words are 92 ========String
the words are 93 ========getLastName
the words are 94 ========(
the words are 95 ========)
the words are 96 ========{
the words are 97 ========return
the words are 98 ========lastName;
the words are 99 ========}
the words are 100 ========public
the words are 101 ========void
the words are 102 ========setBalance(
the words are 103 ========double
the words are 104 ========bal)
the words are 105 ========{
the words are 106 ========balance
the words are 107 =========bal;
the words are 108 ========}
the words are 109 ========public
the words are 110 ========double
the words are 111 ========getBalance
the words are 112 ========()
the words are 113 ========{
the words are 114 ========return
the words are 115 ========balance;
the words are 116 ========}



++++++++this can be a datatype void at 50
+++++++this can be a modifier public at 49
+++++++++the method name is setAccount


the method starts at array54
Method 118 - start at 36 and ends at 45
Method 118 - start at 0 and ends at 46
Method 118 - start at 0 and ends at 47
Method 118 - start at 0 and ends at 48
Method 118 - start at 0 and ends at 49
Method 118 - start at 0 and ends at 50
Method 118 - start at 0 and ends at 51
Method 118 - start at 0 and ends at 52
Method 118 - start at 0 and ends at 53
Method 118 - start at 54 and ends at 57
the position of the method is at 54 and it ands at 57
Method 118 - start at 0 and ends at 58
Method 118 - start at 0 and ends at 59
Method 118 - start at 0 and ends at 60
Method 118 - start at 0 and ends at 61
Method 118 - start at 62 and ends at 65

suppose.... i must be having another statement
the position of the method is at 62 and it ands at 65
from the method thebraces()
But why not?
[ June 10, 2006: Message edited by: catherine matthews ]
 
Don't get me started about those stupid light bulbs.
 
subject: method call
 
Similar Threads
Clarification on execution of try-catch-finally block
3 questions about javascript
Executing procedure in Hibernet with more than one out parameters
Abstract Class calling
Boolean methods