|
||
|
|||
|
Hi, I need to initialise a set in the constructor. I have a set that already contains some values called "numbers" but I need to initialise this set called "newNumbers" with the same values in the constructor. The code I have tried is:
Java Code
public PhoneBook()
{
super();
this.newNumbers = new TreeSet<Integer>();
this.newNumbers = numbers;
}
Thankyou in advance to anyone willing and able 2 help.
|
|
|||
|
thankyou for your response, I want to create a new set containing the numbers that which are being passed for duplication. The numbers are just single numbers not actual phone numbers and there are no 0's..
Last edited by davie; 12-03-2010 at 09:00 PM. |
|
||||
|
Ah. Ok, so what you will need to do is first of all put a parameter for your constructor that gives it the original list of numbers.
Java Code
public PhoneBook(TreeSet<Integer> numbers) Java Code
TreeSet<Integer> newSet = new TreeSet<Integer>(numbers);
__________________
ASCII a question .. Get an ANSI Please surround your code with [highlight=Java]code goes here[/highlight]. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| calling a constructor | turnwellm | What's Wrong With My Code? | 1 | 04-03-2010 12:46 AM |
| Declaring variables in constructor and compiling | Newoor | Object Oriented Programming | 3 | 05-12-2009 05:07 PM |
| Private Constructor | Ganezan | Object Oriented Programming | 4 | 07-11-2009 08:02 PM |
| error cannot find symbol-constructor Person(java.lang.String,java.lang.String,Date) | ss7 | What's Wrong With My Code? | 2 | 03-11-2009 10:28 AM |
| Passing objects as a constructor parameter | derky | Object Oriented Programming | 2 | 27-10-2009 08:31 AM |
|
100 most searched terms
Search Cloud
|
| 2 dimensional arraylist java 2d arraylist java actionlistener actionlistener in java addactionlistener addactionlistener java convert double to integer java double format java double to integer in java double to integer java drag en drop programmeren java eclipse shortcut keys exception in thread "awt-eventqueue-0" java.lang.outofmemoryerror: java heap space exception in thread "main" java.lang.nullpointerexception exception in thread "main" java.lang.outofmemoryerror: java heap space format double in java format double java get mouse position java java 2d arraylist java actionlistener java double format java double formatting java double to int java double to integer java format double java forum java forums java get mouse position java list to map java mouse position java programming forum java programming forums java programming practice problems java send keystrokes to another application java two dimensional arraylist java.io.ioexception: premature eof java.lang.classformaterror: truncated class file java.lang.outofmemoryerror: java heap space java.util.arraylist jbutton action jbutton actionlistener jtextarea font jtextfield font size jxl.read.biff.biffexception: unable to recognize ole stream programming mutators and generics smack api two dimensional arraylist two dimensional arraylist java unable to sendviapost to url what is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? |