Dynamic Size of Class

Hi again. I really don't know why this happens and i need your help here. I have this class:
static public class Data{
        static String subfolder = "";
        static String[] citation = new String[2000];
        static String[] reference = new String[2000];
    }And i create a new variable for this class like this:
Data[] SubFolder = new Data[2000]; Because i need to have, the class organized like this:
SubFolder[0].subfolder = Year0;
SubFolder[0].citation[0] = CITATION1;
SubFolder[0].reference[0] = REFERENCE1;
SubFolder[0].citation[1] = CITATION2;
SubFolder[0].reference[1] = REFERENCE2;
SubFolder[0].citation[2] = CITATION3;
SubFolder[0].reference[2] = REFERENCE3;
SubFolder[1].subfolder = Year1;
SubFolder[1].citation[0] = CITATION1;
SubFolder[1].reference[0] = REFERENCE1;
SubFolder[1].citation[1] = CITATION2;
SubFolder[1].reference[1] = REFERENCE2;
....now, the strange is, when i test the following code:
SubFolder[0].subfolder = "test";
SubFolder[1].subfolder = "test1";
System.out.println(" Position 0 = " + SubFolder[0].subfolder);
System.out.println(" Position 1 = " + SubFolder[1].subfolder);and i print out to console the result is the same! The result is:
Position 0 = test1
Position 1 = test1what i'm doing wrong?? Thanks for your help!

static String subfolder = "";
static in this context means there is only one subfolder value, no matter how many Data objects you create. It belongs to the Data class, not to each instance.
SubFolder[0].subfolder = "test";
SubFolder[1].subfolder = "test1";So the above lines are actually equivalent to:
Data.subfolder = "test";
Data.subfolder = "test1";

Similar Messages

  • How to crate a dynamic size array, collection

    Hi,
    Can someone point me to some tutorial on how to create a dynamic size array. Actually I have multiple cursors and on different tables and want to loop through each cursor and get some values from each cursor and put it in an array. But don't know how to create or initialize an array as I don't know the size. Is there any other way.
    Here is what I am doing I have 6 cursors on different tables, I loop through each cursor and get some specific data that I need to place at one place after looping through all the cursors which then finally needs to be inserted in one table. But before the insert I need to validate each data so want to have all the data in some array or some other place for temporary storage from it's easier to do the validate and insert rather than while looping through the cursors as there may be duplicates which I am trying to remove.
    As this procedure will be called multiple times so wanted to save the cursor data in temporary array before inserting in the final table. Looking for some faster and efficient way.
    Any help is appreciated.
    Thanks

    guest0012 wrote:
    All the 6 cursors are independent and no relation i.e. can have a join and have one sql as no relationship in tables.If there is no relation, then what are your code doing combining unrelated rows into the same GTT/array?
    Now using GTT when I do an insert how do I make sure the same data doesnot already exists. i.e. GTT will only have one column. Then create a unique index or primary key for the GTT and use that to enforce uniqueness.
    So everytime I iterate over a cursor I have to insert into GTT and then finally again have to iterate over GTT and then do an insert in the final table which maybe a performance issue Which is why using SQL will be faster and more scalable - and if PL/SQL code/logic can be used to glue these "no relationship" tables together, why can't that not be done in SQL?
    that's why i was wondering if can use any kind of array or collection as it will be a collection of numbersAnd that will reside in expensive PGA memory. Which means a limit on the size of the collection/array you can safely create without impacting server performance, or even cause a server crash by exhausting all virtual memory and causing swap space to trash.
    and finally will just iterate ovr array and use FOR ALL for insert but don't know what will be the size of the array as I only know after looping the cursors the total number of records to be stored. So wondering if how to do it through collection/array is there a way to intialize the array and keep populating it with the data with defining the size before hand.You cannot append the bulk collect of one cursor into the collection used for bulk collecting another cursor.
    Collections are automatically sized to the number of rows fetched. If you want to manually size collection, the Extend() method needs to be used, where the method's argument specifies the number of cells/locations to add to the collection.
    From what you describe about the issue you have - collections are not the correct choice. If you are going to put the different tables's data into the same collection, then you can also combine those tables's data using a single SQL projection (via a UNION for example).
    And doing the data crunching side in SQL is always superior in scalability and performance, than doing it in PL/SQL.

  • Error editing task sequence: Failed to load dynamic properties for class "SMS_TaskSequence_ApplyWindowsSettingsAction" From XML into WMI

    I've started getting an intermittent error editing my Windows 7 OSD task sequence.  Sometimes I can open the TS to edit, but when I try to apply changes I get the error.  Other times I get the error when trying to open the TS.  If I try again
    right away, I still get the error, but if I wait a few minutes and try again sometimes it will open the TS. 
    The error reads:
    ConfigMgr Error Object:instance of SMS_Extended Status{Description = "Failed to load dynamic properties for class \"SMS_TaskSequence_ApplyWindowsSettingsAction\" from XML into WMI";Error Code = 2147943746;File = "e:\\qfe\\nts\\sms\\siteserver\\sdk_provider\\smsprov\\ssptspackage.cpp";Line = 3454;Operation = "ExecMethod";ParameterInfo = "SMS_TaskSequencePackage";ProviderName = "WinMgmt";StatusCode = 2147749889;}
    Coinciding with this error, I show the following entries in the TaskSequenceProvider.log file: 
    [PID: 7608] Invoking method SMS_TaskSequence.LoadFromXml
    TaskSequenceProvider
    Failed to protect memory buffer, hr=0x80070542
    TaskSequenceProvider
    Failed to load dynamic properties for class "SMS_TaskSequence_ApplyWindowsSettingsAction" from XML into WMI 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load node Apply Windows Settings from XML into WMI 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load children steps for node "PostInstall" from XML 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load children steps for node "Execute Task Sequence" from XML 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load children steps for node "" from XML 0x80070542 (2147943746)
    TaskSequenceProvider
    Failed to load XML for the task sequence into WMI 0x80070542 (2147943746)
    TaskSequenceProvider
    [PID: 7608] Done with method SMS_TaskSequence.LoadFromXml
    TaskSequenceProvider
    Setting status complete:  status code = 0x80070542; Failed to load dynamic properties for class "SMS_TaskSequence_ApplyWindowsSettingsAction" from XML into WMI
    TaskSequenceProvider
    I exported the task sequence and checked in "object.xml" for the "ApplyWindowsSettingsAction", to see if there was something odd in the xml, but I don't find anything that jumps out as being wrong.  Here's the section of XML for
    that step.  I've removed identifying info, and replaced it with a generic term in bold.
    <step type="SMS_TaskSequence_ApplyWindowsSettingsAction" name="Apply Windows Settings" description="" runIn="WinPE" successCodeList="0" runFromNet="false"><action>osdwinsettings.exe /config</action><defaultVarList><variable name="OSDLocalAdminPassword" property="AdminPassword"></variable><variable name="OSDComputerName" property="ComputerName">%_SMSTSMachineName%</variable><variable name="OSDProductKey" property="ProductKey"></variable><variable name="OSDRandomAdminPassword" property="RandomAdminPassword">false</variable><variable name="OSDRegisteredOrgName" property="RegisteredOrgName">COMPANY NAME</variable><variable name="OSDRegisteredUserName" property="RegisteredUserName">COMPANY NAME</variable><variable name="OSDServerLicenseConnectionLimit" property="ServerLicenseConnectionLimit">5</variable><variable name="OSDTimeZone" property="TimeZone">Central Standard Time</variable></defaultVarList></step><step type="SMS_TaskSequence_ApplyNetworkSettingsAction" name="Apply Network Settings" description="" runIn="WinPEandFullOS" successCodeList="0" runFromNet="false"><action>osdnetsettings.exe configure</action><defaultVarList><variable name="OSDDomainName" property="DomainName">DOMAIN.COM</variable><variable name="OSDJoinPassword" property="DomainPassword"></variable><variable name="OSDJoinAccount" property="DomainUsername">DOMAIN ACCOUNT</variable><variable name="OSDEnableTCPIPFiltering" property="EnableTCPIPFiltering" hidden="true">false</variable><variable name="OSDNetworkJoinType" property="NetworkJoinType">0</variable><variable name="OSDAdapterCount" property="NumAdapters" hidden="true">0</variable></defaultVarList></step>
    Is there any other log I should check for a clue on this issue?  What could be causing this error?

    Thanks for sharing that!  I tend to save contacting MS support until after I've exhausted other options.  I'm always afraid that I'll spend the $500 to open a case and then it turns out to be something simple that I would have found if I had just
    kept working on it myself a little longer.
    It looks like that link is for an update released in February as KB3023562.  I downloaded and installed it. I'll try opening/editing/saving the task sequence a few times today to see if the issue is resolved.  
    After I had already installed it, I thought to look up that update in configmgr.  The update is listed as superseded by 2 other updates.  The newest of those is KB3046049, which just installed last night with the other March patches, so it's possible
    that I didn't need to install KB3023562 after all.  

  • Dynamically size movieclip to fit text's string height and width

    Hello,
    I am trying to dynamically size a movieclip to fit the size of a text's string height and width (This text is inside the movieclip)
    here is my code so far..
    var Font1_ = new Font1();
    var Format2:TextFormat = new TextFormat();
    Format2.size = 36;
    Format2.align = TextFormatAlign.CENTER;
    Format2.font = Font1_.fontName;
    var MessageBox:MovieClip = new MessageBoxMC();
    MessageBox.Text1.defaultTextFormat = Format2;
    MessageBox.Text1.embedFonts = true;
    MessageBox.Text1.antiAliasType = AntiAliasType.ADVANCED;
    MessageBox.Text1.wordWrap = true;
    MessageBox.Text1.width = 800;
    MessageBox.Text1.height = 400;
    MessageBox.Text1.textColor = 0xFFFFFF;
    MessageBox.Text1.cacheAsBitmap = true;
    MessageBox.Text1.mouseEnabled = false;
    MessageBox.Text1.text = String("Use the Arrow Buttons to move");
    MessageBox.width = MessageBox.Text1.width;
    MessageBox.height = MessageBox.Text1.height;
      MessageBox.x = 400;
      MessageBox.y = 200;
      addChild(MessageBox);
    this isn't working for me.. anyone know the best way to do this?
    I also want the text to be centered in the movieclip, with a border of around 2-4 pixels
    I am also not sure if i should be using text.length? any advice and input is greatly welcomed.
    thanks in advance!

    Essentially, you need to check for a change in .textWidth or .textHeight, which are different from .width and .height.
    This code works for me (assumes a background box called bg and a foreground text instance fg inside a moveclip and an X and Y bounds offset variable to say how far away you want the box from the text and a textFrameNudge to provide a tweak value).
         // Resize background box
         thisBox.bg.x = thisBox.fg.x - boundsOffsetX + textFrameNudge; // I'm using .4 as the tweak value for textFrameNudge
         thisBox.bg.y = thisBox.fg.y - boundsOffsetY;
         thisBox.bg.width = thisBox.fg.textWidth + boundsOffsetX*2 +textFrameNudge*thisBox.fg.getTextFormat().size;
         thisBox.bg.height = thisBox.fg.textHeight + boundsOffsetY*2;

  • Dynamically loading a class that is part of a larger loaded package

    I am dynamically loading a class that is part of a large package, much of which is loaded at startup. The code directly references protected variables in the parts of the package that is loaded by the default class loader. Attempting to access these protected variables gives an access error when the class is dynamically loaded that doesnt occur when the class is loaded at startup.
    Is there a way to make this work?

    To answer my own question -- no
    A reference from http://access1.sun.com/techarticles/DR-article.html says:
    The use of Dynamic Class Reloading can introduce problems when classes that are being dynamically reloaded make calls to non-public methods of helper classes that are in the same package. Such calls are likely to cause a java.lang.IllegalAccesserror to be thrown. This is because a class that is dynamically reloaded is loaded by a different classloader than the one used to load the helper classes. Classes that appear to be in the same package are effectively in different packages when loaded by different classloaders. If class com.myapp.MyServlet is loaded by one classloader and an instance of it tries to call a non-public method of an instance of class com.myapp.Helper loaded by a different classloader, the call will fail because the two classes are in different packages.
    So not being able to access non-private variables in this scenario is the way it works.

  • Dynamic Java bean classes for XSD using JAVA (not any external batch or sh)

    Hi,
    How can we generate dynamic Java bean classes for XSD (dynamically support All XSD at runtime)?
    Note: - Through java code via only needs to generate this process. (Not using any xjc.bat or xjc.sh from JAXB).
    Thanks

    Muthu wrote:
    How can we generate dynamic Java bean classes for XSD (dynamically support All XSD at runtime)?
    Pretty sure you can't. Probably can do a lot of them with years of work.
    And can probably can do a resonable subset suitable for the business at hand with only a moderate effort.
    Note: - Through java code via only needs to generate this process. (Not using any xjc.bat or xjc.sh from JAXB).The Sun jdk, not jre, comes with the java compiler as part of it. You can create in memory class (I believe in memory) based on java code you create.
    I believe BCEL alllows the same thing (in memory) but you start with byte codes.
    You could just create a dynamic meta data solution as well, via maps and generic methods. Not as fast though.

  • Will size of .class files differ

    Hi All,
    I have compiled a pre compiled .java file on other system, in my system. The size of .class file differed.
    Will this happen, irrespective of systems with same O/S.
    Thanks,
    Aravind

    Hi,
    Yes it can differ. It depends on if you are using the same compiler or not, and if you are building a debug version or not.
    /Kaj

  • Using keyword dynamic before a class

    Hi ,
    I have seen some examples on to Flex , where when creating a ValueObject with ActionScript  , they specify the word  dynamic before
    the class .
    For example see the below code .
    public dynamic class Employee
    private var name:String ;
    private var age:String ;
            public function Employee()
    Thank you .

    So your question probably is what the dynamic keyword does?
    Flex 3 livedocs is your friend: http://livedocs.adobe.com/flex/3/html/help.html?content=03_Language_and_Syntax_10.html

  • Dynamic or Static Class

    Dynamic or Static Objects
    It seems to me there is a big cliff at the point of deciding to instantiate your class at runtime or static load
    on start-up.
    My swf apps have a pent-up burst that happens a couple seconds into the run. I think I get this on most
    web pages that have flash banners.
    Flash apps that have a loader bar can take 60 secs. These ones usually come on with a bang with a lot of
    high quality graphics.
    Therer is a big processor spike at start-up with the browser loading http page. Flash seems to want a big spike
    with its initial load. The javascript embed doesn't help either.
    How to get a smooth start-up? Me English good.
     

    This seems like a matter of correctness, only indirectly relating to speed.
    The speed that a SWF loads from a web page is determined by many things, like server connection speed, client connection speed, browser cache size, client RAM, etc.  Having static vs. dynamic classes would not impact this very much.
    First of all, "static objects" is kind of an oxymoron because you can't instantiate (create an object) of a static class.  I would say that having static variables/methods in a class is usually when you want some shared values/functionality without requiring an actual object (taking up memory) -- although static practices certainly extend beyond just this.  I always try to think of a Math class.  You wouldn't have to have to say m = new Math() just to use some common methods (square, sin, cos, etc.) or values (pi, e, etc.).  They become kind of like "global constants/methods" in a sense (not to invoke the debate over correctness of that wording).
    In short, it's more of a memory issue, which will like not have much influence over loading speed.  If you want to improve your loading speed, you can try to delay the creation of your objects based on certain events instead of having them all load at startup.
    How to get a smooth start-up? Me English good.

  • F4 Help for a dynamic input field( class CL_DD_INPUT_ELEMENT)

    Hi all,
    I am programming a dynamic document which has several input fields on it. I want to program F4 helps for these fields, does anyone have an idea how I can do that?
    I have the idea to program a button(class CL_DD_BUTTON_ELEMENT) next to the input field and manually program an F4 help in the event handler of the button. But I do not know how I can handle pattern entries with '*' etc. in the input field. Is there a function module which could give me an F4 list(F4IF_INT_TABLE_VALUE_REQUEST could not be used, because it needs a dynpro field as a return field, which we do not have in this case).
    Kind Regards,
    Sükrü

    hi
    good
    SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE node.
    allows you to define further nodes for dynamic selections. If the node has type T, you can use TABLE instead of NODE. The user can then decide at runtime the components of the node for which he or she wants to enter selections. Dynamic selections require special handling in the database program
    F4 HELP->
    AT SELECTION SCREEN ON VALUE REQUEST FOR P_SACHA.
        PERFORM VALUES_SACHA.
    THANKS
    MRUTYUN^

  • Dynamic creation of class at runtime

    I need to be able to dynamically create an instance of a
    class that isn't known until runtime - actually based on the
    filename
    so in my fla:
    var className:String="Test"; /* code to get a class name
    derived from the filename */
    var obj = new [className]();
    trace(obj);
    the code above only works if i put the literal directly in [
    like so:
    var obj = new ["Test"]();
    is there a way to do this???
    Any help much appreciated
    cheers Steve

    This might help you out:
    http://dynamicflash.com/2005/03/class-finder/
    "steveanson" <[email protected]> wrote in
    message
    news:e3fcnv$6c7$[email protected]..
    > I need to be able to dynamically create an instance of a
    class that isn't
    known
    > until runtime - actually based on the filename
    >
    > so in my fla:
    > var className:String="Test"; /* code to get a class name
    derived from
    the
    > filename */
    > var obj = new ();
    > trace(obj);
    >
    > the code above only works if i put the literal directly
    in
    > like so:
    > var obj = new ();
    >
    > is there a way to do this???
    > Any help much appreciated
    > cheers Steve
    >
    >
    >

  • Dynamically create a class based on database tables

    I am trying to build a database and tables on the fly, and save to the harddisk(done). Then I need to create a class using the info from the tables on the fly.
    For example,
    I built a database BANK, and a table Customer,
    Customer
    ID
    Phoneno
    Address
    Could I create a class named CUSTOMER (table name)
    dynamically, and have ID, PHONENO, ADDRESS,as the attributes of the class?
    Could anyone help or show the direction?
    Cheers.

    You could use a HashMap, and use the String keys "Customer", "ID", etc, and if you have primitive values like an int, you just wrap it inside Integer or any of the other wrapper classes, because HashMap only works with objects.
    Then you can use an ArrayList to hold all the records (one record is one HashMap as described above).

  • Dynamic Call Function/Class Method

    Hi,
    I have a requirement for which I need your help.
    I want to Call a Method dynamically inside a program. how to do it?
    My another quary is that how to call more than one class method dynamicaly in the program one at a time, based on certain conditions.
    All the requirements mentioned above feels awakward to me, but are they feasible. Eagerly waiting for a reply.
    Regards,
    Pulokesh
    Moderator message - Cross post locked
    Edited by: Rob Burbank on Oct 26, 2009 9:48 AM

    Hello,
    you can call a Method like this where the name of the method is concatenated.
    CONCATENATE 'SC_' me->gf_scenario '_SAVE' INTO lf_method.
      CALL METHOD me->(lf_method).
    Than I can imagine to loop over a tabele with all the Method Call to be executes un there:
    Loop at gt_meth_calls into ls_meth_call.
       ls_meth_call-object_instance->(ls_meth_call-meth_name).
    endloop.
    The table should be structured such that the first component contains a reference to the instance and the second component will be the Method name to run.

  • Dynamically Loading a Class with Parameters

    Hi,
    I'm working on small program during my spare time and I have run into a problem. I have one abstract class (Foo) which is extended by several other subclasses (subFoo1, subFoo2). I am trying to avoid making a whole host of if statements depending on user input by coding in dynamic class loading.
    The newInstance() method I've read about works well except that it does not accept arguments, something that I sorely need:
    Foo a = Class.forName(input).asSubclass(Foo.class).newInstance();The other method works for creating the objects but I get an error:
    Class foo = Class.forName(input);
    Constructor cons = cs.getConstructor(new Class[]{String.class, Long.TYPE});
    Object a = cons.newInstance(new Object[]{ FooString, FooInt});
    a.method()
    cannot find symbol
    symbol : method(java.math.BigDecimal)
    location : java.lang.ObjectI can understand the problem that the new 'Object' can't find the methods of 'foo', but i don't know how to solve the problem.

    Object a = cons.newInstance(new Object[]{ FooString, FooInt});
    a.method();That isn't very strange, is it? a is an Object, and class Object doesn't have the method you're calling. You have to cast it to a Foo:
    Foo a = (Foo)cons.newInstance(new Object[]{ FooString, FooInt});
    a.method();

  • Dynamic names for class and variable

    Hi Folks,
    How do you make a new instance of a class with a dynamic name.
    var dynamicname = new dynamicname()
    i try something
    var this["test"]:Class = new ["Test"]()
    but offcourse its not this...
    I need this couse i have a librairy with SWC fonts they are only reference.. I get the font name from a CSS file and after i need to make a instance of the SWC file so the font is embedded.
    Thanks anyone who can help me!
    Cheer, Michierl

    Btw Murphy its not working......
    var fontRef = Class(getDefinitionByName("Arial"));
    var font = new fontRef();
    trace(font);
    The varibable definition not defined.
    I have 5 fonts as SWC Files set as reference lib in flex.
    But i dont wann to load all fonts yet cosue that will make my movie 200kb ... so i copy the fontname of the stylesheet and then make a instance of that font class.
    But how? With yours it need already a refrences to that class.

Maybe you are looking for

  • SALES order creation using BAPI's

    Hai to all, I want to create sales order using bapis .I am new to this topic could any body guide me how to create sales order  step by step process using bapis. Thanks in advance. Regards, Chaitanya

  • IPod touch not showing up in finder, under devices.

    My iPod doesn't show up on finder. It should come up under devices but all that is there is my mac, and firefox. I really need it to be there so please help.

  • About ESB and JBI

    Hi there, Can somebody help me out in testing out JBI in an ESB framework. I need simple examples to understand the ESB framework and JBI. Thanks in advance,

  • How can i adjust my screen brightness​? HP ProBook 4530s

    I cant adjust my screen brightness. Fn+f2, f3 show the brightness bar at the dimmest point and doesnt make any change. The manual way of going through Control Panel then display, personaisation also doesnt work. I am running Win 7 Pro registered vers

  • 7mm SSD too small for my x61s

    Hi, I just bought a new SSD to replace the HDD I had. The SSD works well, but it's currently being held in place by paper, since it was too thin to fit the rubber railings that kept the original HDD in place. Does anyone know any products that reliab