What is this - Object[] x = {new String[]{"a","b"}};

What is the meaning of this -
Object[] x = {new String[]{"a","b"}};
I have a function which takes Object[] as a argument. And I have data structure like this -
Name = Zoolander
Name = Hansel
Name = Mugatu
I am not interested in the Name part. This has to be converted to - Object[] x = {new String[]{"a","b"}}
It works if I hard code the values like this -
Object[] x = {new String[]{"Zoolander","Hansel","Mugatu"};
Thanks in advance

Don't crosspost, please.

Similar Messages

  • New String(byte[]) taking up huge space?

    Ok. I have a byte[] of approx. 5.000.000 bytes. Whenever, at any point, I try to create a String using this array by new String(array), my memoryusage increases by about 60/65 megabytes. Can anyone please explain me why on earth it's doing this?
    Note also that this space is not freed up by the GC (afterwards).
    Thanks in advance

    Actually, I've discovered some details about the swing textcomponents. They're very bad for 'simply' showing 2mb+ files.
    Check out these bugs; original and "more recent".
    It doesn't quite explain why putting a byte array to a string occupies twice the space, but it does seem to account for the huge memory increase when putting it to a JTextArea.
    String is immutable so it has to copy your char[] to
    a new char[] backing the String. If it used theSure thing, but I'm passing on a byte[] array, and afaik, it's not using this array and should only copy it. Once.
    Oh hey, could it be that the bytes are saved in unicode? That would double the size... and make sense...
    Oh and PS; Maybe you should read this if you really think strings are immutable... (although you are generally correct :))

  • String name = new String {...} what is this?

    Hi,
    Java beginner, moving from C++:
    protected String[] name = new String[] {
              Integer.toString(1),
    Integer.toString(2)
         };what does a bracket mean after new String[] ?
    Thanks,

    Thanks, I didn't know what to search for in
    google...
    Is it generalizable to any object?Why don't you try it with various objects and primitives? Then you'll find out for yourself.
    You can also read the JLS
    http://java.sun.com/docs/books/jls/second_edition/html/j.title.doc.html
    or
    http://java.sun.com/docs/books/jls/third_edition/html/j3TOC.html
    Or any of a number of books or tutorials. This is basic stuff. It should be covered.
    Sun's basic Java tutorial
    Sun's New To Java Center. Includes an overview of what Java is, instructions for setting up Java, an intro to programming (that includes links to the above tutorial or to parts of it), quizzes, a list of resources, and info on certification and courses.
    http://javaalmanac.com. A couple dozen code examples that supplement The Java Developers Almanac.
    jGuru. A general Java resource site. Includes FAQs, forums, courses, more.
    JavaRanch. To quote the tagline on their homepage: "a friendly place for Java greenhorns." FAQs, forums (moderated, I believe), sample code, all kinds of goodies for newbies. From what I've heard, they live up to the "friendly" claim.
    Bruce Eckel's Thinking in Java (Available online.)
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java.

  • What happens to objects when you redeclare a new object?

    ... and is there a more proper way of "deleting" them from memory, or is it a case of waiting until the garbage collector in java sweeps them up?
    i.e.
    private CustomObjectType myObject;
    public final void myMethod() {
    myObject = new CustomObjectType("I am the first object");
    // do some temporary work with myObject
    /// now I need to do more work with another temporary object, so just replace the "link"
    myObject = new CustomObjectType("I am a second object");
    Is it better to declare new variables to hold this second object?
    Should a person declare the object to be null when no longer required?
    Do I ever need to worry about this, does the garbage collector sort out references for me?
    (Please go easy, still learning and don't really need to know this right now but I'm curious! :)

    What happens to objects when you redeclare a new object?If you go:
    Dog myDog = new Dog();
    and then go:
    Dog myDog = new Dog();
    you are replacing the first reference to Dog() with another one. I don't think it would make sense to do this because it is redundant.
    But if you go:
    static Dog myDog = new Dog();
    and then go:
    static Dog myDog = new Dog();
    then then second one will be ignored because the first one already assigned Dog() to myDog.. so the second one won't replace the first one - it will just be ignored or generate an error.
    is there a more proper way of "deleting" them from memory, or is it a case of waiting until the garbage collector in java sweeps them up?In c and c++ you have to think about when the life of an object ends and destroy the object to prevent a memory leak. But in Java the garbage collector takes this task on if a certain amount of memory is used. If you don't use a lot of memory the gc won't bother and the objects will be destroyed when you exit the program.
    You can use:
    finalize(){
    // insert code to be executed before the gc cleans up
    and if you call System.gc() (which you probably won't need to do) then the code in the finalize() method will run first e.g. to erase a picture from the screen before collecting the object.
    private CustomObjectType myObject;public final void myMethod() {
    myObject = new CustomObjectType("I am the first object");
    // do some temporary work with myObject
    /// now I need to do more work with another temporary object, so just replace the "link"
    myObject = new CustomObjectType("I am a second object");
    you could do:
    public class CustomObjectType{
        //this constructs an instance of the class using a string of your choice
        CustomObjectType(String str) {
            System.out.println(str);
        static void main(String[] args){
            CustomObjectType myObject = new CustomObjectType("I am the first object");//  This sends the constructor the string you want it to print
            CustomObjectType myObject2 = new CustomObjectType("I am the second object");//  This sends the constructor the string you want it to print
    }Bruce eckel wrote Thinking in Java 4th edition considered to be the best book on Java because of how much depth he goes into, although some recommend you should have atleast basic programming knowledge and a committment to learn to get through the book.
    I just started it and it helps a lot. Maybe u could borrow it from the library.. good luck!

  • Monitor object instantiation of an arbitrary class, e.g. new String(...)

    Hello,
    does anyone have an idee how to monitor object instantiation of arbitrary java class, e.g. new String(...).
    Is the 'VMObjectAlloc' the right place or should this be done using BCI?
    Many thanks,
    Christian

    Thanks a loot swamyv !!
    Can you give me any hint where such a step could be done? Should i "scan" the bytecode inside the CLASS_REPARE event processing? What would be the thing i'm looking for?
    Thanks in advance,
    Christian

  • Setting the name of a new object from a string

    Is there anyway I can set the object name of a newly created
    object from a string?
    eg.
    (the code below generates a compile time error on the
    variable declaration)
    public function addText(newTxt:String, txt:String,
    format:TextFormat):void {
    var
    this[newTxt]:TextField = new TextField();
    this[newTxt].autoSize = TextFieldAutoSize.LEFT;
    this[newTxt].background = true;
    this[newTxt].border = true;
    this[newTxt].defaultTextFormat = format;
    this[newTxt].text = txt;
    addChild(this[newTxt]);
    called using>
    addText("mytxt", "test text", format);
    I could then reference the object later on without using
    array notation using mytxt.border = false; for example
    There are many a time when I want to set the name of a new
    object from a string.
    In this example I have a function that adds a new text object
    to a sprite.
    The problem is, if I call the function more than once then
    two textfield objects will exist, both with the same name. (either
    that or the old one will be overwritten).
    I need a way of setting the name of the textfield object from
    a string.
    using
    var this[newTxt]:TextField = new TextField()
    does not work, If I take the "var" keyword away it thinks it
    a property of the class not an object.
    resulting in >
    ReferenceError: Error #1056: Cannot create property newTxt on
    Box.
    There must be a way somehow to declare a variable that has
    the name that it will take represented in a string.
    Any help would be most welcome
    Thanks

    Using:
    var this[newTxt]:TextField = new TextField()
    is the right approach.
    You can either incrment an instance variable so that the name
    is unique:
    newTxt = "MyName" + _globalCounter;
    var this[newTxt]:TextField = new TextField();
    globalCounter ++;
    Or store the references in an array:
    _globalArray.push(new TextField());
    Tracy

  • TS3297 "iTunes was unable to load data class information from Sync Services." What is this solution for the new phone to sync up with my iTunes acct?

    "iTunes was unable to load data class information from Sync Services." What is this solution for this new phone to sync up with my iTunes acct?

    Hi tadhunt,
    Here is an article that directly addresses that error message:
    iTunes for Windows: "Unable to load data class" or "Unable to load provider data" sync services alert
    http://support.apple.com/kb/ts2690
    I hope this helps!
    - Ari

  • Can anyone answer this question? What is used to format a string so that it falls into a certain Row/Column in excel? see text for indepth question.

    I'm attaching a file that may help. Just remember this is my FIRST attempt at using NI/FeildPoint so things that would be obvious to the normal users more than likely would slide right by me. So I'll try and explain what the text contains as to make my problem more clear. I'm using a FP-1000, FP-AI-100, and a FP-TB-10. i'm creating a application where I'm using the 8 channels from the FP-AI-100 to monitor a control system ,that we manufacture. The control system is in an environmental chamber. I use the FP-TB-10 to monitor the temperature while in the chamber. The control system is ran for 4 hours under varing enviromental conditions while I monitor vital system voltages with the FP-AI-100. Now the application that i'm building starts with the obvious FP CREATE.VI and so forth I have no problem communicating with the FP's, but the information that I'm monitioring needs to be placed into a file with Headers describing the information below it. Now I use a "WHILE LOOP.VI" to monitor the FP-AI-100 & FP-TB-10 for the 4 hour period. but before that I create and open a file where I use a "CONCATENATE STRINGS.VI" to enter the headers I need. I do this by CONSTANTS, CONTROLS, TABs, AND CARRIAGE RETURN being entered into the "CONCATENATE STRINGS.VI" in the order I want them to appear. I use ROW 1 to enter (OPERATOR:with a CONSTANT) an a (CONTROL so the operator may enter his name and be recorded into the file) using a TAB to seperate Columns and a CARRIAGE RETURNto drop down to ROW 2 for the next headers. I use header names and TABs to seperate the columns. This part works great. I end up with ROW 1 having the operator information then ROW 2 having the headers for all the channels I'm using to monitor the control system with in their own column. The trouble happens when I write to this file during the "WHILE LOOP". The information recorded for DATE:, TIME:, and Channel 0 of the FP-AI-100 end up right under their corresponding header on ROW 3, but the rest of the data ends up on ROW 4 in column 3 and goes down many rows with some of the data not being stored at all. It varies on how many rows are used starting at ROW 4 but hey always stay in column 3. I use the "FP READ.VI" outputing to a "ARRAY TO SPREADSHEET STRING.VI" outputing to a "CONCATENATE STRINGS.VI" for each channel within the "WHILE LOOP" then into the "WRITE.VI". I use the "CONCATENATE STRINGS.VI" to place my data OR atleast I thought you could do that some how I'm not quit doing something write either there is a sampling/timing issue or writing to file issue where things are being confused in the "WHILE LOOP" if someone know a better route to perform what I'm tring here I would be interested. Its not like I'm not giving it the old colledge try here but without proper training and the vagness of the manuals it's difficult to understand what every connection actually does.I'm tring though for everyone who happens to fill pity for me
    Thanks for your help
    John Morris
    Glendinning Marine Product, Inc.
    Attachments:
    ALLchannels ‏273 KB

    > I appreciate your effort to help me, but there is still a slight cloud
    > in front of my eyes here.(I must mention that I'm using Labview 5.1
    Oh, to bad. I'm using LV 6,02 and tried to save the application as LV5.1,
    but it didn't work.
    > Lets start with the easy one which is the SECOND main thing you
    > wanted to mention. In my application I used individual Create Tag.vi's
    > "so your saying that I can use just one Create Tag.vi and one Read.vi
    > and what ever I use to display the values will automatically to show
    > the individual channels" in other words if I use a "Indicator(DBL)"
    > comming out of the Read.vi what ever I use in the "PANEL" layout will
    > expand to show all 8 channel if I was using a FP-AI-100? Cool...
    Allmost right. The 8 channels come out as 1D-array, ch0...ch7.
    > #1--How do I change the delimiter (TAB) to a delimiter (comma) in a
    > Array to Spreadsheet String.vi?
    > ...cut
    I don't use this Spreadsheet VI, because files coming out there allways
    start this time consuming EXCEL wizzard. Because of this, I programmed my
    own CSV-conversion vi. Maybe you could just use a common texteditor, like
    wordpad and put the csv-examples from my last reply down to a text file
    and rename it to *.csv. Texteditors terminate lines with "\r\n" by
    default, so this is a very quick way for testing.
    > FP_Analog_Logging example to record all eight channels it uses a Array
    I didn't find the vi you metione above, but there is another good one:
    Look at examples\FieldPoint\DataLogging\FP Logger.vi.
    In a little case structure, at "false", there is a function called "Format
    into string".
    Pop up on the format string and adjust >>'\' Codes Display<<.
    Then you change the format string into: %.;%-f%s
    A Tab string is connected to the lower input of this function. Replace
    this one with a comma.
    That should do.
    >
    > #2--If using just one Create Tag.vi and one Read.vi and I have the
    > Item Name listed as ALL I take it that the information comming out of
    > the Read.vi is data for each channel in a String format starting with
    > channel 0 and ending with channel 7 for the FP-AI-100.
    Yes, just as explained above. If you put a indicator at the output to
    display the values, you can expand the display to show all 8 channels, but
    you can't name induvidual cells. In a array, all cells have identical
    named labels. If you want to name the individually, you have to attach the
    array to cluster function and put the indicator after this one. Enable
    labe display and name the output values individually.
    > #3--Now I use the following to "Format String" in the Array to
    > Spreadsheet string.vi (%.4f)but I don't see anyway of changing the
    > delimiter from (TAB) to (COMA)
    Explained above.
    > #4 you stated text strings need a "as prefix and sufix" and each
    > string is seperated by a coma, a period is used as decimal number
    > separator and lines have to be terminated by my question is
    > WHERE IS THIS ACCOMPLISHED? WHAT VI OR WHAT CONNECTOR PIN?
    Well, modifying strings are done with string functions.
    Above, as I explained how the sample FP Logger.vi can be modified to do
    the job for numbers. The pre- and suffixing with ", you only need for
    strings, which EXCEL should interpret a string and as nothing else as a
    string, even if there's a number inside. You usually need this only for
    headers. So its easyest, if you just write your string into a string
    constant or control and concatenate it to the previous csv-file contents.
    Oh, I just see by looking at the above mentioned example... Inside the
    case structure, but in the "true" case, there are error messages
    concatenated to the logfile. At this point it is importent, to use " for
    integrating the message into the CSV file, because a error message usually
    looks like this: >> ERROR 2345 in vi yxz <<
    Here you have text and number strings mixed in one line. EXCEL does not
    know, if it should interpret the number inside the error line as separate
    number, separating the line into three colums i.e. string before number,
    number and string after number. So tell EXCEL by putting a " before and
    after the line each.
    For this, expand the Format To String function by one input, move down all
    connections, to be able to insert a string constant with a " to the first
    argument connector. Change the contents of the string constant at the
    bottom argument from tab to ", (quotation mark AND comma)
    > #5 You gave me an example of what a 3 column header could look like:
    > "col0","col1","col2"\r\n Now is this something that you enter
    > somewhere cause I know that \r is carriage return and \n is newline so
    > I take it that the above is entered somewhere maybe in the Write.vi to
    > the connector called Header (F)? See this is what confuses me because
    > NI manuals have no examples of certain connectors types being used or
    > any reference as to how they manipluate data with there varing type
    > inputs. Or maybe I'm just missing them.
    The example I mentioned above help here to.
    Look at the Write File function. This function receves data from a
    function named concatenate strings. Expand this function to have one more
    spare input at the bottom. Create a string constant. Switch the constant
    display to "\" mode. Enter "col0","col1","col2"\r\n into the constant.
    Connect the constant to the spare input.
    Doing this, every dataline in the csv file is followed by
    "col0","col1","col2"\r\n .
    I wish you a nice weekend,
    Rainer Ehrt

  • HT5625 I'm trying to create a new Apple ID but when I was putting on my information, there's a box asking for an ITunes gift code. What's this and how can I get one?

    I'm trying to create a new Apple ID but when I was putting on my information, there's a box asking for an ITunes gift code. What's this and how can I get one?

    You're not obligated to insert a gift code. But you can purchase gift codes on the Apple online store (gift cards or certificates) or Apple Retail store
    Gift codes are pre paid cards so you can use credit on the iTunes Store to purchase content
    To create apple ID without payment method:
    http://support.apple.com/kb/HT2534?viewlocale=pt_PT

  • When downloading the new 10.7 update for itunes, an error message saying that there is an error writing to file, verify that you have access to this file comes up... what is this??

    When downloading the new 10.7 update for itunes, an error message saying that there is an error writing to file, verify that you have access to this file comes up... what is this??

    That one's consistent with disk/file damage. The first thing I'd try with that is running a disk check (chkdsk) over your C drive.
    XP instructions in the following document: How to perform disk error checking in Windows XP
    Vista instructions in the following document: Check your hard disk for errors
    Windows 7 instructions in the following document: How to use CHKDSK (Check Disk)
    Select both Automatically fix file system errors and Scan for and attempt recovery of bad sectors, or use chkdsk /r (depending on which way you decide to go about doing this). You'll almost certainly have to schedule the chkdsk to run on startup. The scan should take quite a while ... if it quits after a few minutes or seconds, something's interfering with the scan.
    Does the chkdsk find/repair any damage? If so, can you get an install to go through properly afterwards?

  • In Pages 09 we can do Mail Merge and Import Styles from a document. Can someone please explain how we can do this with the new version of Pages 5.1. Even Apple solutions are only valid for Pages Version 09. What a DOWN GRADE!

    In Pages 09 we can do Mail Merge and Import Styles from a document. Can someone please explain how we can do this with the new version of Pages 5.1. Even Apple solutions are only valid for Pages Version 09. What a DOWN GRADE! Thank god Pages 09 is still there.

    …and the other 98 missing features.
    Just use Pages '09, which should be in your Applications/iWork folder.
    Rate/review Pages 5 in the App Store.
    Peter

  • Screen Message"File iTines Library.itl cannot be read because it was created by a newer version of iTunes" What is this and how can it be fixed?

    Screen Message on P.C. "File "iTunes Library.itl" cannot be read because it was created by a newer version of iTunes.
    What is this and how can it be fixed, please?

    Problem solved by doing the following:
    Open PC/Mac and search for iTunes Library.
    From the list, select the most recent version of iTunes Library. Save this to a folder.
    Delete iTunes from your computer.
    Install latest version of iTunes.
    When I opened the new version of iTunes, everything was there as before.
    I didn't need to import the saved version of iTunes Library. Maybe this happens automatically?????

  • TS1717 When I click the itunes icon on my laptop and error message appears "new itunes library" What does this mean?

    I can't open Itunes. It just says "new itunes library" and closes. What does this mean?

    See Empty/corrupt iTunes library after upgrade/crash.
    tt2

  • I'm trying to download my Master CS6 onto a new hard drive because my old one crashed and I keep getting a message saying " Cannot write the file" or "I don't have permission to access the requested resource." ? What does this mean?

    I'm trying to download my Master CS6 onto a new hard drive because my old one crashed and I keep getting a message saying " Cannot write the file" or "I don't have permission to access the requested resource." ? What does this mean?

    Yes- it is a Mac. I went through adobes system requirements and re- downloaded supportive software. The notice seems to happen near the end of the down load with the messages above. I'll look into your suggestion. Thank you- appreciated.

  • Menu Object; MANUAL option. What is this, and how does it work?

    What is this... and, how does it work? Can't find documentation on this.

    My knee-jerk reaction is, "are f'n kidding me?"... but, of course, you're not.
    I must say, that is an incredibly useless option. How would that 'option" differ from simply making a text object (or text/rectangle/image combo or group) and creating a link?
    What got me looking at this option was the hope to find some way to insert a dynamic "field" that could be used on a master page to display the current page title (of a page based on that master). Something similar to Word (and other applications) that you can enter information into a document property and then insert that information anywhere within the document by using a field code for that info. I don't know if there is an HTML code that could be used to accomplish this, in this case. Something that would refer to the page title.
    Thanks for the info none-the-less.

Maybe you are looking for

  • Function module for getting teh last working day of a month.

    Hi GURUS, this is criteria,please help me  if V_T001B- FRYE1 < month entered in selection screen           Then throw the error message             Else Find the previous period and its last working day from the function module       (i..e Assume ent

  • Workflow- Purchase order

    Hi When i was working on 800 Client for Workflow configuration i had the predefined template for Release Procedure for Purchase order i like to copy the same template and i have to work on my Business Requirement template if i want to copy that one s

  • The sims 2 disc won't load

    When I put in the disc for the first time, it doesn't appear on my desktop. When I go to applications it appears there but when I click on 'Open' nothing happens and whatever else I click on either comes up with a load of random writing or a picture

  • Airport Extreme to https websites

    Via wifi, have no problem accessing the normal http websites and access is blocked to https websites. However no access problem to https websites using an ethernet cable. Looks like a problem with my Airport Extreme security setting. Thanks for your

  • Mail app on imac is not working

    mail app will not load the page completly and i get the pizza wheel of death andmail does not load.