Hashtable and double array

Hi,
i need to store a series of double arrays in a hashtable.
now while extracting them i get ClassCastException
can anyone tell me how to extract a double array from a hashtable. if its not possible then can i use any other data structure
thanx

Cast it correctly?double[] darray = (double[])yourHashtable.get(yourKey);And if that doesn't work, then post the code where you put the "double array" into the Hashtable.

Similar Messages

  • How do i convert a double array (with spaces and tabs) to a string?

    Hi
    In our files, we have a mixture of spaces and tabs as a delimeter. How do I convert a double array into a string?
    Thank you.

    Not sure about the last part of your question.
    The Search and Replace pattern can be better than the simple Search and Replace string when you have to do complex searchs, such as detecting multiple spaces.
    Have a look at the attachment.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    ReplaceSpaces.vi ‏27 KB

  • Error in converting double to double array

    Iam getting a problem while coverting the values of a table to double array local variable . while the values r getting from the resultset using while(rs.next())
    all the values have to store in the double array.please give me solution to this problem.

    Show us your code and the problem you are facing.

  • Most efficient way to strip nulls from a Double[] array?

    I'm trying to optimize performance of some code that needs to accept a Double[] array (or a List<Double>) and fetch the median of the non-null values. I'm using org.apache.commons.math.stat.descriptive.rank.Median to fetch the median after converting to double[]. My question is how I can most efficiently make this conversion?
    public class MathStatics {
         private static Median median = new Median();
         public static Double getMedian(Double[] doubles) {
              int numNonNull = 0;
              for (int i = 0; i < doubles.length; i++) {
                   if (doubles[i] != null) numNonNull++;
              double[] ds = new double[numNonNull];
              for (int i = 0; i < doubles.length; i++) {
                   if (doubles[i] != null) ds[i] = doubles;
                   System.out.println(ds[i]);
              return median.evaluate(ds);
         public static void main(String[] args) {
              Double[] test = new Double[] {null,null,-1.1,2.2,5.8,null};
              System.out.println(MathStatics.getMedian(test));
    I'm sure that the code I wrote above is clunky and amateurish, so I'd really appreciate some insight into how to make improvements. FWIW, the arrays will typically range in size from ~1-15,000 doubles.
    Thanks!

    There's no need to loop over the array twice
              int numNonNull = 0;
              double[] ds = new double[numNonNull];
              for (int i = 0; i < doubles.length; i++) {
                   if (doubles[i] != null) {
    numNonNull++;
    ds[i] = doubles;
                   System.out.println(ds[i]);
    Except that ds will have length zero, so you'll get a OutOfBoundsException every time you use it.
    As you're using Doubles rather than doubles, you can add the non-null values to an ArrayList and then convert it to an array at the end.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Converting Object Arrat to double array

    public double average(Object ... object)
              double avg=0;
              int count=1;
              for (double d: object)
                   count++;
                    avg +=d;
              return (avg/count);
         }I wanted this code to get compiled with out making much changes(I do not want to change the parameter type of the method).I am gonna pass a double array as an argument to this method.And how could I test that the argument is a double array.

    Pravin
    I don't know if this is exactly what you want, but it is as close as I could make it to your post, and it compiles.    public double average(Object ... objects) {
            double avg = 0;
            int count = 1;
            for (Object d : objects) {
                count++;
                try {
                    avg += (Double) d;
                } catch (java.lang.ClassCastException e) {
                    System.out.println(e.toString());
                    System.out.println("Element No." + count +
                            "is not a valid double.");
            return (avg / count);
        }Please elaborate if you need something more.
    db

  • Double array

    Is there double array in java? If I want to create a list, and each element in the list is another list, how can I implement this?
    Sorry for posting these kinds of questions, but I can't seem to find the correct place to for such things.
    Thx

    http://java.sun.com/docs/books/tutorial/java/data/multiarrays.html
    - Mr K

  • Vectors : Converting to double[ ] array

    Hello,
    I have a vector which I know consists of double values only. I am trying to create an array of double from this vector but am having some difficulty.
    Firstly if I try this :
    double[] high = (double[])datavector.high.toArray(new double[0]);JBuilder reports :
    'Cannot find method toArray(double[])'
    But if I try this :
    Double[] high = (Double[])datavector.high.toArray(new Double[0]);It works.
    So from this I assume 'Double' is not equal to 'double'
    The trouble is I require 'double[ ]' and NOT 'Double [ ]'.
    Casting Double as (double) does not work... so how do I get double[] from my original vector ?
    Many thanks
    Kerry

    double[] d = new double[v.size()];
              int i = 0;
              for(Iterator<Double> it = v.iterator(); it.hasNext();)
                   d[i++] = (double)it.next();
              just declare the double array to be the size of the vector, then loop thru and populate the array one at a time
    ~Tim

  • Howto when i have very very large double array

    I have code my program about document retrieval.
    I create double array in size [10000]x[8000] for keep value for calculte someting in only memory (about metrix operation).
    I have set parameter to heap memory size at 1024m but it not enough, it has exception out of memory.
    I use Notebook that have RAM 1G. Is this cause for exception?
    Please help me to lead solution for my case.
    Thank you.

    anurag.kapur wrote:
    A couple of points:
    1. Your notebook has 1 GB of RAM and you are allocating 1024 MB (=1 GB) to the JVM heap, which is not possible, as you need some space for running various other Operating System processes as well.This is a good point. There are also things in the JVM itself other than the Java object heap that need space. Thread stacks, loaded classes, native libraries, etc.
    2. Why have you allocated 1024 MB to the JVM heap? Did you choose any random number (obviously with some degree of educated guess)?
    Your array size is 10000 * 8000 = 8 * 10^7
    Thus total heap memory required = 8 * 10^7 * 4 Bytes [The int data type is a 32-bit signed two's complement integer]
    = 320 * 10^6 Bytes
    = 320 MBExcept that peterdog1234 said that the array was an array of doubles, at 8 bytes each, so about 640MB are needed for the array. If the algorithms allow the loss of range and precision, maybe the array could be an array of floats, not doubles. That would keep the array in about 320MB. That would help with the space requirements, but might be slower as all the operations will have to expand the floats to be operated on as doubles, then converted back to floats for storage in the array. But on some architectures that's not too bad.
    I would use -XX:+PrintGCDetails to see how the heap has been partitioned into young generation (fast allocation and collection) and old generation (relatively long-lived data). You might have to reshape the heap to have at least 640MB in the old generation, and then whatever you can fit as the young generation, leaving some of your 1GB for the rest of the JVM, other programs running on the box, the operating system, etc. Maybe "-Xms768m -Xmx768m -XX:NewSize=64m -XX:MaxNewSize=64m" would be a good compromise. That gives you a 768MB Java object heap, with 64MB in the young generation and 704MB in the old generation, leaving 256MB (1GB-768MB) for "other things". Whether that works depends on now many other long-lived Java objects you have. But -XX:+PrintGCDetails will tell you that, too.

  • Converting a hashtable to an array (CORBA sequence)

    Hi all,
    I wish to convert the contents of a hashtable to an array (well a CORBA sequence), but I am having a bit of trouble.
    I have a CORBA struct called 'Equipment', and an unbounded sequence of Equipment structs called 'EquipmentList':
              struct Equipment {
                   string name;
                   string description;
              typedef sequence<Equipment> EquipmentList;I have a Java hashtable called equipmentList which contains a list of equipment with key 'name' and corresponding value of 'description'.
    The following code is trying to convert from the hashtable to the CORBA sequence:
              Equipment equipList[] = new Equipment[equipmentList.size()]; // make sequence same size as hashtable.
              for (int i = 0; i < equipmentList.size(); i++) {
                   equipList[i] = new Equipment(); // make element a valid 'Equipment' object.
                   equipList.name = equipmentList.name; // give each sequence element value 'name' the value of the hashtable key value 'name'
                   equipList[i].description = equipmentList.description; // same with 'description' value
    I know the conversion is completely wrong, and it obviously brings up 2 errors a compile time:HireCompanyServer.java:81: cannot find symbol
    symbol : variable name
    location: class java.util.Hashtable
    equipList[i].name = equipmentList.name;
    ^
    HireCompanyServer.java:82: incompatible types
    found : java.lang.Object
    required: java.lang.String
    equipList[i].description = equipmentList.get(equipList[i
    ].name);
    ^
    Note: Some input files use unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    2 errors
    I know this might be a long-winded question, but I am having real difficulty fixing this, and would kindly appreciate some more advanced programmers to give me any hints or fixes for my code.
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    JonBetts2004 wrote:
    I know this might be a long-winded question, but I am having real difficulty fixing this, and would kindly appreciate some more advanced programmers to give me any hints or fixes for my code.Not quite sure how 'struct' got in there, but unless you're using generics to set up your HashTable, you have to cast anything you get from your list to the correct type. Have a look at the HashTable method list and I think you'll work out what you want.

  • For dynamically allocated double arrays, sizeof() does not work

    For a typical double array, if you need to get the size, you would use
    numElems=(sizeof(myArray)/sizeof(myArray[0]));
    However, for dynamically allocated double arrays (see here for example) this no longer works.
    For the example above, sizeof(myArray) returns 4, and sizeof(myArray[0]) returns 8.
    Solved!
    Go to Solution.

    That's because sizeof(myArray) is the size of the pointer to the dynamically allocated array.
    sizeof(myArray[0]) is the size of a double (8 bytes).
    If you know the size you malloc'd then just use this instead of the sizeof(myArray) function.
    Array size (for use in bounds checking for example) is a compile-time thing in C89 (though CVI will hack in run-time bounds checking for you in a debug compile).  So even if you cast a malloc'd buffer pointer to an array type, the compiler's out of the picture at run time when the buffer gets established to a (potentially) run-time determined size, so it can't help you.  More modern languages (e.g. Java, C#) all get around this problem.  C99 allows variable length arrays to be declared but I'm not sure NI implemented this in their C99 upgrades.

  • Copy NIVector to double array

    Hi,
    is there an easy way to copy data from an CNIReal64Vector to a double array?
    I tried to use the STL copy algorithm, but the tricky thing is that I have to copy the last element myself. Ugly...
    The method gets a pointer to an array : double* autoSpectrum1[]
    CNiReal64Vector niAutoSpectrum;
    MathError errorNI = CNiMath::AutoPowerSpectrum(timeDataVector, niAutoSpectrum, df, dt);
    size = niAutoSpectrum.GetSize();
    *autoSpectrum1 = new double[size];
    std::copy(&niAutoSpectrum[0], &niAutoSpectrum[size-1], &(*autoSpectrum1)[0]);
    (*autoSpectrum1)[size-1] = niAutoSpectrum[size-1];
    Any idea?
    Thanks
     Mario

    Hi Mario,
    Here your "double* autoSpectrum1[]" is a table of pointer.
    When you have, you can do is to do a "For Loop" and copy the element of the table pointed from your "autoSpectrum1" table and save it in a 2D table...
    I think that is the best way to do that...
    Regards...
    Matthieu

  • Float and Double - 5.1 divide by 3.0

    Hi everyone,
    I am quite new to java programming in term of using it. I wrote a test class to learn about float and double. However when I wrote the below code, I got a strange result. So, I wonder if java's float and double have any kind of exception I should be aware of. This won't happen if I just change from 3 to other numbers. Any suggestion? Thanks in advance.
    public class MathTest {
    public static void main (String args[]) {
    float f1 = 5.1F;
    float f2 = 3.0F;
    double d1 = 5.1;
    double d2 = 3.0;
    System.out.println("Float result : " + f1/f2);
    System.out.println("Double result : " + d1/d2);
    Result:
    Float result : 1.6999999
    Double result : 1.7

    This is due to the way that binary numbers convert to digital numbers and is expected. See these threads for explanations:
    http://onesearch.sun.com/search/onesearch/index.jsp?qt=%2Bprecision+%2Bwrong+double&col=developer-forums&rf=0&chooseCat=allJava&subCat=siteid%3Ajava

  • With Mavericks I have to hold command key down and double click to get a sub folder to open in a new window.  Can I go back to just double clicking ?

    With Mavericks I have to hold command key down and double click to get a sub folder to open in a new window.  Can I go back to just double clicking ?

    Of course. To do it, open a Finder window, go to Finder menu (on the menu bar) > Preferences > General, and untick "Open folders in tabs instead of new windows".

  • Outlook 2010 apostrophe, single and double quotes are changes to question mark while sending mails to other internet receipient.

    We are using MS Outlook 2010 as our mail client. But we have noticed that whenevr we sent a mail to any other internet mail recipient all the "apostrophe", "single" and "double quotes" have automatically converted to ?. We have
    done almost all the workaround found in this site such as
    1.New a message and focus on the message window > click File > Options > Mail > Spelling and Autocorrect… > Proofing > AutoCorrect Options… > AutoFormat > clear the box before “Straight quotes” with “smart quotes”
    2. Used different encoding. We presently using US-ASCII for outgoing message. etc.
    Need your help to sort out these issues urgently.
    Waiting for a solution.

    Hi,
    What is your account type? IMAP, POP or Exchange?
    Send an email from the webmail, ask the recipient if this issue persists.
    As far as I know, this problem is always related to the encoding for outgoing messages, and here I suggest you try UTF-8:
    Go to File -> Options -> Advanced -> International options -> Uncheck "Automatically select encoding for outgoing messages", then select "Unicode (UTF-8)" beside "Preferred encoding for outgoing messages" -> OK.
    Hope this helps.
    Regards,
    Melon Chen
    TechNet Community Support

  • No DNS and Double NAT

    Hello, I've recently encountered a very frustrating bug in my system that I could use some help troubleshooting.  I've read several similar posts, some are resolved while others are not, however none of the resolutions have worked for my situation.  Here it goes:
    I have an old macbook pro, a new macbook air, a white macbook and 2 iPhone 4s's all connected to the internet via WiFi through an AirPort Extreme.  The AE is connected to a cable modem which has internet service through Cablevision in NY.  There is also an AT&T Microcell hooked up to the AE to boost my cell signal.   All of this equipment has been working flawlessly together for a long time.  Until recently.  It could have started after an update, there have been several lately on all of the equipment including the firmware in the AE.  Anyway, I'll be connected without any issues - all lights green and happy - when suddenly, the internet will drop off and the AirPort Utility will pop up and warn me that:
    1) On the "internet" icon, it will say "disconnected"  
    2) On the AE icon, it says "No DNS server and Double NAT"
    After a few minutes and nothing done on my part, the lights turn green, the internet reconnects and all is well again. 
    This happens frequently and is really beaching a nuisance.  Due to the frequency of the disconnection, I can no longer download a large file, update, or anything.  Streaming video is impossible.
    So far, I have tried bridge mode and cycled the power in the order recommended to no avail.  When I do that, the AE turns green, but the internet says "not connected".  I have also read that there might be too many IP addresses which is not sitting well with my ISP, so I disconnected everything including unplugging the Microcell.  Lastly, there are no other wireless phones or devises in the house.  All to no avail.
    I should also mention that this began occurring on my Time Capsule, which I replaced with the AE in an attempt to fix this issue. 
    Any help would be greatly appreciated.
    Joe

    Sounds very similar to what I've been trouble shooting for 2 months now, only I have DSL from AT&T and I don't see the Double NAT warning.  My last post on the problem is here. 
    My only emergency solution for getting by day to day on the internet is to unplug the AE and connect one Mac directly to the DSL modem.  There's no shared connection or WiFi.  I looked at hosting WiFi from the Mac, but the only security available with that is WEP which isn't considered secure.  Even with this set up, I think (seat of the pants) that there are quality of service problems. 
    I've replaced the Airport Extreme with 2 different new units and the DSL modem with a new unit to no avail.  The Genius Bar and Apple phone support couldn't solve this, nor have 2 calls to AT&T support and one visit from an AT&T repairman.
    I would like to know how to better test or quantify the poor quality of connection that seems to be the problem.

Maybe you are looking for

  • Cs5.5 master collection wont install After Effects or Premier

    Just upgraded from CS4 to CS5.5 and installation errors on After effects and Premier. I'm running windows 7 64 bit pro service pack 1,Duel x5650 xeons,  24 gigs of memory, 250 gb ssd. Before installing CS5 I uninstalled cs4. After the first installat

  • How do I find out what "new" features, if any, are in incremental version updates to CC?

    In olden days, Adobe would tell you what was fixed and what was added to new micro-versions of a product. I've noticed now that when I get an update to Photoshop or Bridge, it can be over 100mb but nowhere does it say what the update is for like new

  • Nikon D300s images too bright and interlaced.

    So this is my first time shooting and editing video and I'm getting some weird errors. I'm running Windows 7, and when I view the video files after downloading them from the card, the whites all seem too bright and blown out, no matter which media pl

  • Phasenabweichung & Frequenzbestimmung von 2 Signale

    Mein System wird 2 Signale aufnehmen: die Kraft(N) und die Geschwindigkeit(m/s) für unterschiedliche Frequenzen, die von DIAdem 9.0 eingestellt werden, zwischen 5 und 150 Hz. Für jede Frequenz werden Messungen und Aufnahmen durchgeführt. Die signale

  • Proxy to proxy scenario

    Hi All, I am working on Proxy interface. My interface is like below ECC 6---- >PI (7.1) - >SRM I had done the entire configuration in ECC and PI for proxy activation. While testing the interface in ECC system messagesis not processing from ECC, but t