Yet another not working thingy mabob
publicclass inttest{
publicstaticvoid main(String[] args)
{
int days;
days = 1000;
days();
}
publicstaticvoid days(){
System.out.println("There is now "+days+" left.");
}
}
All help appreciated with why this isn't working. By the way, this is the error: inttest.java:12: cannot find symbol
symbol : variable days
location:class inttest
System.out.println("There is now "+days+" left.");
^
1 error
Press any key tocontinue . . .
[1175 byte] By [
Zacha] at [2007-11-27 2:24:23]

days is local to the main() method. Other methods can't see it. Read the section in this article about variable scope.
http://java.about.com/od/beginningjava/l/aa_vars1.htm
Both of these will work.
public class Test
{
int days;
public static void main(String args[])
{
days = 1000;
printDays();
}
public static void printDays()
{
System.out.println(days);
}
}
/* - */
public class Test
{
public static void main(String[] args)
{
int days = 1000;
printDays(days);
}
public static void printDays(int numDays)
{
System.out.println(numDays);
}
}
Umm, ok thanks. Anymore suggestions? Morgan, your first one did not work. Thanks though.
Zacha at 2007-7-12 2:31:21 >

> days is local to the main() method. Other methods
> can't see it. Read the section in this article about
> variable scope.
>
> http://java.about.com/od/beginningjava/l/aa_vars1.htm
>
> Both of these will work.
> public class Test
> {
>int days;
>public static void main(String args[])
> {
>days = 1000;
> printDays();
>}
>public static void printDays()
> {
>System.out.println(days);
> }
>
> /* - */
>
> public class Test
> {
>public static void main(String[] args)
> {
>int days = 1000;
> printDays(days);
>}
>public static void printDays(int numDays)
> {
>System.out.println(numDays);
>
> }
For the first example, days needs to be made static, because you're accessing it from within static methods.
> For the first example, days needs to be made static,> because you're accessing it from within static> methods.Yup, thanks for the correction. Trying to answer questions while watching 300 doesn't work so well. ;-)
Is 300 good? I want to see that.
Zacha at 2007-7-12 2:31:21 >

> Is 300 good? I want to see that.It's probably the best movie I've ever seen.Did you read through that link I gave you?
Yes, and it wasn't helpful much...
Zacha at 2007-7-12 2:31:21 >

> Yes, and it wasn't helpful much...That isn't helpful either.
> ...> questions while watching 300 doesn't work so well. ;-)You mean the South Park episode? http://www.southparkx.net/stream/episode-1106-stream
> > ...> > questions while watching 300 doesn't work so well.> ;-)> > You mean the South Park episode?> http://www.southparkx.net/stream/episode-1106-streamNo, 300 is a new Movie.
Zacha at 2007-7-12 2:31:21 >

> You mean the South Park episode?No! It's a movie about the Spartans at the [url= http://en.wikipedia.org/wiki/Battle_of_thermopylae]Battle of Thermopylae[/url]. It didn't come out in the Netherlands?
> > You mean the South Park episode?
>
> No! It's a movie about the Spartans at the
> [url=http://en.wikipedia.org/wiki/Battle_of_thermopylae]Battle of Thermopylae[/url]. It didn't come out in
> the Netherlands?
Yes, it's out here as well. It was some sort of a joke, sorry.
; )
I must be honest: liked South Park's parody better than the trailer of [the movie] 300.
> > Is 300 good? I want to see that.> > It's probably the best movie I've ever seen.Better than Citizen Kane?
> Yes, it's out here as well. It was some sort of a
> joke, sorry.
That's where sarcasm tags come in. ;-)
> I must be honest: liked South Park's parody better
> than the trailer of [the movie] 300.
I have to be honest, I'm not a huge South Park fan. I prefer The Family Guy over South Park. You should really see 300 when it comes out on dvd (or blu-ray!).
> Better than Citizen Kane?...I wasn't alive in 1941.
> > > Is 300 good? I want to see that.> > > > It's probably the best movie I've ever seen.> > Better than Citizen Kane?Probably not. But if we're talking about classics: 12 Angry Men is IMO far better!
> > Better than Citizen Kane?> > ...I wasn't alive in 1941.True, but where you alive in 480 BC? :-)
> > > Better than Citizen Kane?> > > > ...I wasn't alive in 1941.> > True, but where you alive in 480 BC? :-)No, but I was alive in 2007 when the movie was made. ;-)