Results 1 to 7 of 7
  1. #1
    wayenng is offline Member
    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0

    Default problem on printf() method

    Hi all,
    when i compile my programe, error occurred as below,
    i don't know how to fix it correctly...can anyone help me?
    thanks a lot

    PS. my java version is 1.6

    C:\java>javac UseInnerClass.java
    .\OutClass.java:37: cannot resolve symbol
    symbol : method printf (java.lang.String,int,int,int)
    location: class java.io.PrintStream
    System.out.printf("Point[%d]: x = %d, y = %d%n",
    ^
    1 error


    ===================
    public class OutClass {
    // Inner Class
    private class Point {
    private int x, y;

    public Point() {
    x = 0; y = 0;
    }

    public void setPoint(int x, int y) {
    this.x = x;
    this.y = y;
    }

    public int getX() {
    return x;
    }

    public int getY() {
    return y;
    }
    }

    private Point[] points;

    public OutClass(int length) {
    points = new Point[length];

    for(int i = 0; i < points.length; i++) {
    points[i] = new Point();
    points[i].setPoint(i*5, i*5);
    }
    }

    public void showPoints() {
    for(int i = 0; i < points.length; i++) {
    System.out.printf("Point[%d]: x = %d, y = %d%n",
    i, points[i].getX(), points[i].getY());
    }
    }
    }

    ==============

    public class UseInnerClass {
    public static void main(String[] args) {
    OutClass out = new OutClass(10);

    out.showPoints();
    }
    }

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,652
    Blog Entries
    7
    Rep Power
    21

    Default Re: problem on printf() method

    What version of Java are you using?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: problem on printf() method

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    wayenng is offline Member
    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0

    Default Re: problem on printf() method

    Hi JosAh,

    As mentioned, it is java version 1.6.

    Thanks a lot.

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: problem on printf() method

    And what's your javac version?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    wayenng is offline Member
    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0

    Default Re: problem on printf() method

    when i run "java -version", it display follow,
    java version "1.6.0_26"
    Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
    Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)

    and at the beginning, i used the cmd to compile...while i used the eclipse, it's worked.
    is it because of the lib? or something else?
    please advise

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,422
    Rep Power
    20

    Default Re: problem on printf() method

    Quote Originally Posted by DarrylBurke View Post
    And what's your javac version?
    Quote Originally Posted by wayenng View Post
    when i run "java -version", it display follow,
    Read the responses.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. printf VS printWriter.printf
    By Mapisto in forum New To Java
    Replies: 14
    Last Post: 01-20-2012, 12:29 PM
  2. Concerning a small output problem with PRINTF
    By Kaizer in forum New To Java
    Replies: 2
    Last Post: 11-04-2011, 06:27 PM
  3. Printf problem!!!
    By pinar in forum New To Java
    Replies: 3
    Last Post: 11-06-2010, 09:44 PM
  4. printf() method explanation needed
    By darek9576 in forum New To Java
    Replies: 1
    Last Post: 03-14-2010, 03:54 AM
  5. Demonstration of printf() method
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •