Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within OCPJP
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Ron McLeod
Junilu Lacar
Liutauras Vilda
Sheriffs:
Paul Clapham
Jeanne Boyarsky
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Piet Souris
Carey Brown
Bartenders:
Jesse Duncan
Frits Walraven
Mikalai Zaikin
Forum:
Programmer Certification (OCPJP)
var-arg and array problem
Mohit G Gupta
Ranch Hand
Posts: 634
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public class Widening1 { static void go(int...x) {System.out.println("widening to simple int"); } static void go(int[] a2) {System.out.println("array"); } static void go(int a,int b) {System.out.println("simple"); } public static void main(String arg[]) { go(4,4); Byte a=12; go(a,a); } }
output:
cannot declare both go(int[]) and go(int...) in Widening1
static void go(int[] a2)
^
1 error
please explain ?
OCPJP 6.0 93%
OCPJWCD 5.0 98%
Chinmaya Chowdary
Ranch Hand
Posts: 437
I like...
posted 12 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi, Mohit.
static void go(int...x) {System.out.println("widening to simple int"); }
Here var-args internally represented as array, like
static void go(int[] x){ ..... }
Compiler will do this. There is a conflict. There should be one.
SCJP5.0, SCWCD5.0, OCEJPAD6, OCPJWSD6
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
can parent class constructor be invoked using this operator?
Conversion.....
passing Array between methods
why variables inside interface has to final
Making 2-D array from 1-D Array.
More...