How come this doesn't work?

System.out.printf("Age: " + age + "%40s", "Name: " + name); age = console.nextLine(); name = console.nextLine();and i have name and age as strings.It says that the variables might not have been initialized.
[242 byte] By [Kaisa] at [2007-11-26 22:21:04]
# 1

> System.out.printf("Age: " + age + "%40s", "Name: " +

> name);

> age = console.nextLine();

> name = console.nextLine();

>

> and i have name and age as strings.

>

> It says that the variables might not have been

> initialized.

put the age=concsole.nextLine(); and name=console.nextLine() before the System.out.println..

MS

Progr@mera at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...
# 2
And if that doesn't work make sure u initialize name and console as String name, console;
Progr@mera at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...
# 3
You aren't setting the values of age and name until after they are used; so they probably still haven't been initialized.
ignignokt84a at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...
# 4
> And if that doesn't work make sure u initialize name> and console as > String name, console;That's not "initializing" them, that's declaring them. Initializing them requires you to assign a value (an "initial" value) to them.
dcmintera at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...
# 5

When i put

age = console.nextLine();

name = console.nextLine();

before

System.out.printf("Age: " + age + "%40s", "Name: " + name);

you have to enter to things and then it will print it to age and name. It won't prompt you with age, which you enter, then come up with name, which you enter.

It will just go:

17

Michael

Age:17 Name:Michael

Kaisa at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...
# 6
You should put print statements that say something like "Enter Age:" before getting the age value from the command line. Do the same thing for name.
ignignokt84a at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...
# 7
> It won't prompt you with ageNo shit Sherlock! If you don't include it in your code are you expecting it to read your mind?
floundera at 2007-7-10 11:18:36 > top of Java-index,Java Essentials,Java Programming...