5-8 LocalVar
Post date: Mar 29, 2014 5:27:12 PM
//Thls program demonstrates that two methods may have local variables with the same name.
package localvar;
public class LocalVar
{
public static void main(String[] args)
{
texas();
California();
}
// The texas method has a local variable named birds.
public static void texas()
{
int birds = 5000;
System.out.println("In texas there are " + birds + " birds.");
}
// The California method also has a local variable named birds.
public static void California()
{
int birds = 3500;
System.out.println("In California there are " + birds + " birds.");
}
}