Results 1 to 7 of 7
Thread: problem on printf() method
- 12-29-2012, 08:33 AM #1
Member
- Join Date
- Dec 2012
- Posts
- 14
- Rep Power
- 0
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();
}
}
- 12-29-2012, 09:13 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,429
- Blog Entries
- 7
- Rep Power
- 17
Re: problem on printf() method
What version of Java are you using?
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-29-2012, 09:45 AM #3
Re: problem on printf() method
Why do they call it rush hour when nothing moves? - Robin Williams
- 12-29-2012, 10:09 AM #4
Member
- Join Date
- Dec 2012
- Posts
- 14
- Rep Power
- 0
Re: problem on printf() method
Hi JosAh,
As mentioned, it is java version 1.6.
Thanks a lot.
- 12-29-2012, 11:43 AM #5
Re: problem on printf() method
And what's your javac version?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 01-01-2013, 05:36 AM #6
Member
- Join Date
- Dec 2012
- Posts
- 14
- Rep Power
- 0
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
- 01-01-2013, 05:58 AM #7
Similar Threads
-
printf VS printWriter.printf
By Mapisto in forum New To JavaReplies: 14Last Post: 01-20-2012, 12:29 PM -
Concerning a small output problem with PRINTF
By Kaizer in forum New To JavaReplies: 2Last Post: 11-04-2011, 06:27 PM -
Printf problem!!!
By pinar in forum New To JavaReplies: 3Last Post: 11-06-2010, 09:44 PM -
printf() method explanation needed
By darek9576 in forum New To JavaReplies: 1Last Post: 03-14-2010, 03:54 AM -
Demonstration of printf() method
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:37 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks