| | |
Help Needed
![]() |
•
•
Join Date: Apr 2007
Posts: 1
Reputation:
Solved Threads: 0
Okay I am trying to get an array (a primitive integer array) called a1 which contains integers. I want to return an ArrayList that has the entries of a1? This should be really simple, but it is just one of those days....
like
like
Java Syntax (Toggle Plain Text)
public static ? formlist(//a1 is sent as a parameter so int a1[] ?) { }
For example you can do like this. It all depends on your requirments.
import java.util.ArrayList; public class ArrayPass {ArrayList<Integer> arraylist = new ArrayList<Integer>();public ArrayList<Integer> MyArrayList(int [] a1){for(Integer a : a1){}arraylist.add(a);System.out.println(a);} return arraylist;public static void main(String [] args){}ArrayPass ap = new ArrayPass();ArrayList<Integer> a = new ArrayList<Integer>();int [] a1 = {1,2,3,4,5};a = ap.MyArrayList(a1);for(Integer b : a)}{System.out.println(" after passing : "+ b);}
![]() |
Similar Threads
- Harddrive failure and 100% CPU under Win2K, Help Needed! (Windows NT / 2000 / XP)
- XP PRO iis help needed (Windows NT / 2000 / XP)
- CWS. help needed (Viruses, Spyware and other Nasties)
- are all these needed (Windows NT / 2000 / XP)
- help much needed !! (OS X)
Other Threads in the Java Forum
- Previous Thread: Excel implementation help
- Next Thread: Need Advice on for loops with vowels
Views: 854 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Java
add android applet application arguments array arraylist arrays c# c++ chat class classes client code component constructor convert coordinates data database db desktop detection eclipse error event exception file forloop fractal givemetehcodez graphics gridlayout gui helpwithhomework homeworkassignment html ide image images inheritance input integer interface j2me java javafx jframe jpanel jtextarea jtextfield key lazy linked linked-list list loop looping method methods mobile netbeans newbie node number object oracle output page parameter pattern pixel problem programming read recursion remove return robot scanner search server service set size sms software sql string swing system text text-file threads time timer translate tree user





