| | |
printf and three string arguments
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Hi all, I hope you are well. I am trying to compile a java file using terminal in Ubuntu, but I am getting the following error message:
As you can see, I am passing three String arguments to the printf method, which, as far as I can tell from the API is perfectly legal as this would correspond to the object varargs printf method.
Interestingly, this compiles & executes fine in NetBeans (on the same machine, so same JDK version). Please can someone tell me if I have missed something here? Many thanks.
•
•
•
•
1. ERROR in StringComparisons.java (at line 20)
System.out.printf("String a = %s String b = %s \n", a,b);
•
•
•
•
printf
public PrintStream printf(String format,
Object... args)
A convenience method to write a formatted string to this output stream using the specified format string and arguments.
Last edited by majestic0110; Oct 16th, 2009 at 1:24 pm.
Computers are man's attempt at designing a cat: It does whatever it wants, whenever it wants, and rarely ever at the right time.
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 54
0
#2 Oct 16th, 2009
bug?
test:
compile one test at the same time
post result
test:
Java Syntax (Toggle Plain Text)
String format = "String a = %s String b = %s \n"; System.out.printf(format, a, b); System.out.printf("String a + %s String b + %s \n", a, b); System.out.printf(new String("String a = %s String b = %s \n"), a, b); System.out.printf("String a " + "=" + " %s String b " + "=" + " %s \n", a, b); System.out.printf("String a " + '=' + " %s String b " + '=' + " %s \n", a, b);
post result
•
•
Join Date: Nov 2008
Posts: 332
Reputation:
Solved Threads: 54
0
#6 Oct 19th, 2009
Compile with additional javac options to obtain more info:
? odd.
check also from command line version of java
if 1.5 - bad
if >1.5 - ok.
http://java.sun.com/docs/books/tutor...berformat.html
Java Syntax (Toggle Plain Text)
javac -help javac -version javac -g -verbose StringComparisons.java pause
check also from command line version of java
if 1.5 - bad
if >1.5 - ok.
http://java.sun.com/docs/books/tutor...berformat.html
•
•
•
•
Here is a basic example:
int i = 461012;
System.out.format("The value of i is: %d%n", i);
The %d specifies that the single variable is a decimal integer. The %n is a platform-independent newline character.
Last edited by quuba; Oct 19th, 2009 at 11:50 am.
![]() |
Similar Threads
- Acessing indefinte arguments for a function? (C++)
- Counting an inputted letter in an inputted string using getchar() (C)
- command line arguments help (C)
- Reverse string arrays (C)
- Simply question: How do I return a string from a function (C)
- Sane way of dynamically allocating arrays beyond declaration. (C)
- hellp please (Java)
- Array Values not found in Methods (Java)
- Program Compiles fine, but error upon Running (Java)
- Reversive Array/Integer (C)
Other Threads in the Java Forum
- Previous Thread: How to resolve an indirect html url?
- Next Thread: Client - Server Application
| Thread Tools | Search this Thread |
Tag cloud for arguments, java, netbeans, printf, terminal, ubuntu
.net age ajax amd apple applet array avatar bluegene c++ canonical centos chips class classes clear code component database debian dell desktop development distributions dos eclipse economy energy enterprise error event fedora freebsd game google gui hardware html ibm ibm.news image input intelibm itunes java jetbrains jsp julia knoppix linux loop mac marketshare medicine memory method microsoft mysql netbeans netbook netbooks newbie news novell openoffice opensource opensuse operatingsystems os pc php problem program programming project ps3 python recession redhat russia security set socket software sun supercomputer supercomputing swing technology terminal threads tree trends ubuntu virtualization web windows working x86 youtube







