Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Nov 30th, 2007, 12:19 PM   #1
nightFix
Newbie
 
Join Date: Nov 2007
Posts: 4
Rep Power: 0 nightFix is on a distinguished road
retaining values in methods

Hello,
I'm pretty new to OOP and Jave and have ran into an issue on how to code some logic. I have a method that's needing to hold a local variables value upon different calls. I have tried this code but realize that Java can only use static keyword for classes. ( I think i have the code right, my code came off of a different computer that does not have internet access. I think I have remembered it correctly though.)
private float proc(int a, int b, boolean state){
if(state == true){
             //do processing here
             static int complete = 1;
             return result;
}else{
if(complete != 1){
             //do same processing here
}
// more processing
return result;
}
I then switched it to this but Java won't compile it due to a possible initiation issue.
private float proc(int a, int b, boolean state){
Integer completed;
if(state == true){
             //do processing here
             completed = 1;
             return result;
}else{
if(completed != 1){
             //do same processing here
}
// more processing
return result;
}
Any advice will greatly be appreciated.
nightFix is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help on save and save as methods Yarvin Python 2 Nov 9th, 2006 8:01 PM
Arrays as Parameters in Methods grimpirate Java 2 Jun 22nd, 2006 11:01 PM
Returning two values Navid C 19 Jun 13th, 2005 2:57 AM
A standards question, optional inputs into Methods Arla C# 4 Apr 27th, 2005 10:38 PM
Problem Inserting Values into mySQL from PHP stakeknife PHP 1 Mar 23rd, 2005 8:45 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:51 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC