-2
package age;

import java.util.Scanner;

public class AgeTest 
{
  public static void main(String[] args)
  {
    Scanner input = new Scanner(System.in);

    Age myAge = new Age();

    System.out.printf("initial age is :%s%n%n"+ myAge.getAge());

    System.out.println("PLEASE ENTER THE AGE");
    int theAge = input.nextInt(); 
    myAge.setAge(theAge);
    System.out.println();
    // display the name stored in object myAge
    System.out.printf("age in object myAge is %n%s%n"+ myAge.getAge());

What is wrong?

Felix G.
  • 6,365
  • 2
  • 16
  • 24
nad
  • 1
  • 2

1 Answers1

0

I guess your getAge() method is returning an int. So try parsing the myAge.getAge() to String like:

String age = Integer.toString(myAge.getAge()) System.out.print("Age is: " + age );

Miquel Perez
  • 445
  • 1
  • 6
  • 17
  • Change your `System.out.printf("initial age is :%s%n%n"+ myAge.getAge());` line for this ----> `System.out.printf("initial age is :%s%n%n"+ Integer.toString(myAge.getAge()));` and do the same in the last printf. – Miquel Perez Feb 16 '16 at 17:30