The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


static variable in Class4

Posted by ping203 on January 10, 2002 at 2:30 PM

you can put a static variable in Class4 to store the total
and have another to check if there is no more input. I just
assume when count == 3, there is no more input.

class Class4
static int sum = 0;
static int count = 0;
int intakeValue1;
int i = 0;
public Class4(int intakeValue)
intakeValue1 = intakeValue;
sum += intakeValue1;
System.out.println("The amount just entered is " + intakeValue1);
if (++count == 3)//no more input???
System.out.println("The sum " + sum);
sum = 0;
count = 0;


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us