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:
Campbell Ritchie
Tim Cooke
paul wheaton
Jeanne Boyarsky
Ron McLeod
Sheriffs:
Paul Clapham
Liutauras Vilda
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Bartenders:
Forum:
Programmer Certification (OCPJP)
Enhanced for loop
Juwonlo Ibigbami
Ranch Hand
Posts: 83
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi in the house, please can eny body explain to me how to used enhanced for loop to asign value to an array of array at runtime using scanner
Juwonlo(
scjp
prep.)
Jesper de Jong
Java Cowboy
Posts: 16084
88
I like...
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Can you post some code to explain your question more clearly? What have you tried yourself, and where do you get stuck exactly?
Jesper's Blog
-
Pluralsight Author Page
Juwonlo Ibigbami
Ranch Hand
Posts: 83
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanks,Explainingmyselfbetter,
Given:
int[][] a =new A[5][]
How can i use the enhanced for loop to assing values to the arrays inside array decleared above.
Omer Haderi
Ranch Hand
Posts: 42
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Aloha...
There is no such thing in
java
int[][] a =new A[5][]
...
If you mean int [][]a = new int[4][]; then you can use it like this in the enhanced loop:
int [][] a = new int[4][]; int []vals = {3, 4, 5,6}; // add some values first and then print a[0] = vals; for(int []x: a) { if(x != null) for(int value: x){ System.out.println(value); } }
PS: is it difficult to separate the words when asking questions ?
cheers!
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Array reverse
problem with enhanced for loop
Colon : in for{} loop?
Can u be a tad less obscure?
using enhanced for insted of while - for reading resulset
More...