Question about creating objects

Around the web and in a few books I have seen code similar to this:
List records = new ArrayList();
My question is, why is "List" used instead of "ArrayList"?? So the code would like so:
ArrayList records = new ArrayList();
What are the benefit(s) of assigning ArrayList object to a superclass variable??

It allows you to change the implementation on that
one line, for example, to:
List records = new LinkedList();
//or
List records = Collections.synchronizedList(new
ArrayList());without having to change the code elsewhere. And ask
yourself -- does
the code elsewhere in the class need to know that
records is an instance
of ArrayList, versus some other list type?Interesting, but then you would lose the additional methods that the derived class adds correct? So you have to make some sacrifices for more robustness.

Similar Messages

  • Question about creating objects in Forms 6i

    Hi,
    I'm trying to create by code dynamic items in a form, but I don't find the way to do it, or any tutorial in the internet.
    Taking a look at the Forms Help it says 'Once you create a data or control block, you can create items in that block at any time. Create items via the Object Navigator by inserting them under the desired block, or via the Layout Editor by drawing them on the desired canvas.'
    Is there a way to create items and assign them to datablocks by code? something like CREATE_ITEM?
    All I want is a button that inserts textboxes in a canvas, as many items as you want.
    Thank you in advance

    Hello,
    There is no Create_item() built-in to create item at runtime.
    You can create hiden item at design time then show them at runtime.
    Or you can use some java code to create component at runtime.
    Francois

  • A question about creating packages as local objects in ABAP

    Hi,
    I have a question about creating packages with SE80. Whenever I create a new package it is assigned a new transport request. After that, I can create new programs inside this package, and each time I can choose whether to assign the new program to a transport request or just save it as a local object (I often do this for test programs that I don't transport and I remove them once my tests have been done).
    What I would like to ask is that, is it possible to create a package (and not just programs inside a given package) as a local object? so that every new object created in this package will be considered as a local object?
    Thanks in advane,
    Kind Regards,
    Dariyoosh

    Thomas Zloch wrote:
    Please also check the F1 help for the package field e.g. in SE80, SAP standard is in range A-S and U-X, namespaces start with "/", so you should be save. I am using the T namespace for temporary stuff since a long time and did not have a problem so far.
    > Thomas
    >
    > P.S. this applies to the package name only, of course
    Thank you very much for this remark, I checked F1 help for the package field and in fact as you mentioned these ranges are for local objects.
    Once again, thank you very much for your help.
    Kind Regards,
    Dariyoosh

  • A question about creating READ ONLY users.

    Dear all,
    I have a question about read only user accounts and I would appreciate if you could kindly give me a hand. I have a schema named SCHEMA1. Whenever I want to connect by using sqlplus I run the following:
    sqlplus user1/[email protected] SCHEMA1.WORLD is the entry in the tnsnames.ora referring to the schema SCHEMA1.
    I need to create a read only user who is able to SELECT all tables and views created by user1 on SCHEMA1 (this user will not modifiy anything at all. The user is used only for a person using SQL queries to read data). for several tables I write the grants explicitly, for example:
    CREATE USER user2 IDENTIFIED BY user2;
    GRANT CREATE SESSION to user2;
    GRANT SELECT ON S001_COR_ECLASS TO user2;
    GRANT SELECT ON REF_ECLASS511 TO user2;Is there anyway to do the same thing but for all the tables (because there are a lot of tables and views)? Besides, even with these granted permissions when the user connects with SQL Developer to the database, he is not able to view the list of tables/views in SQL Developer GUI. What causes this problem?
    Thanks in advance,
    Dariyoosh

    Hello Dariyoosh,
    he is not able to view the list of tables/views in SQL Developer GUIyou can either go to "Other Users" - user1 - tables. There you see every table you have permission to select.
    Or you can create a synonym in schema2 for each table in schema1 and set a filter on the tables node of user2 "Include synonyms".
    Regards
    Marcus

  • Question about creating Jtable from a "Self Made" object.

    Hi all,
    I am new to java and this is my first post here.
    First of all, i want to say nice to meet u all. This is a blessed forum, and it already helped me a lot.
    I hope that i will be clear with my question.
    Now to the question:
    I have created a class that reads parameter file and its meta file and combine them (each parameter in the file gets its properties such as "Mask", "Default" and else from the meta file) to one object (the class creates collection of instance of it self that has a get method.
    the class also has method that get "Column Names" from the instance.
    I want to create a Jtable that will present these parameter(each row will present 1 parameter).
    Only the second column should be editble and it should choose the editor by the type of data (example: if it is boolean should get a check box, i has more than one "ValidValue" should get a combo box and so on).
    What would be the best way to do that?
    I am not looking for a source code, I am looking for concept suggestion.
    This project is for "Self Learning" porpuse, and any help will be gratitude.
    Thanks a lot you all,
    On Katalan.

    Use the Adapter pattern (http://en.wikipedia.org/wiki/Adapter_pattern) to wrap your object as a TableModel.
    eg, if your data class is "ParameterSet" you might do this...
    public class ParameterSetTableModel implements TableModel
        private final ParameterSet set;
        public ParameterSetTableModel(ParameterSet set)
            this.set = set;
        public String[] getColumnNames()
            return this.set.getColumnNames();
        // you'll need to implement all TableModel methods, either
        // directly calling the wrapped object or calling it and
        // converting the data, or whatever's appropriate
    }

  • Question about creating new objects

    When creating a DocumentBuilderFactory Object, why is the code written like this:
    DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();as opposed to
    DocumentBuilderFactory docBuilderFactory = new DocumentBuilderFactory();???

    Factory classes like this are typically abstract classes which do little more than define an interface and the getInstance() methods. The class that getInstance() will actually instanciate will be a concrete implementation from a particular implementation of the DOM parser. This pattern allows whatever implementation happens to have been supplied to be automatically be used without your code having to concern itself.
    The concrete factory will then create concrete implementations of the various interfaces like DOMPaser, using the implementations in the actual library.

  • Question about Creating DataSources for FlatFile Data Acquisition

    Hello eveyone,
    I am trying to create flatfile datasources.  I've been checking out the existing ds in my dev system and there are some infrastructure here that have loaded data in them, all via their won flatfile DS.  I've been looking at the DS and am trying to figure out logic in which they are defined. I saw that most of the fields are defined in CHAR even if they pertain to fields like quantity, Amount and so on...  They are also in the Internal format.  Yet they have been successfully loaded...
    My question is:  what are the rules of thumb in defining the DS?  How do i go about in mapping the fields to objects in the system?  Can anyone please give me the step-by-step scenario as to how to do this please?
    Many thanks,
    Philips

    Hi Philip,
    Pls. try the following steps ..may be helpful.
    1. when ever you want to create a flat file structure..keep in mind that, what are
        fields data available in your file. second thing is you need to know the IO of
        the info provider in which you are uploading.
    2. simply create your own DS with PC File, and other hand open up your infprovider, and keep on check with your flat file what is the sequence of the data
    fields and what are they corresponds to in the cube/ODS
    3. As your flat file sequence, keep on identify the related IO of your provider and
    copy it individual and paste it in your infosouce one by one as sequence of your
    flat file..
    4. No need to think of what type of data it is and how it is..
    5. simply copy all your correponding IO (what ever of their type) even including
        some of the ref. IO.
    6. And finally save and activate your DS creation.
    I hope it would help in creating your own Flat File DS.
    Need further info revert...
    Cheers,
    Thanks=Points.

  • Questions about smart objects in CS3-CS5.

    Hi.
    Two questions.
    When I replace content of smart object in CS2 the content takes the size of previous state of smart object in pixels.
    It was very useful when need to replace some background to another and it autoresized to the new size and proportion.
    For example, when I replace content of smart object with external size 100x90px and 100x90% proportion (can see with Ctrl-T) with file with 200x300px size, i have new smart object with old size 100x90px and new proportion 50x30%.
    When I try to do the same in CS3-CS5 I get smart object with size 160x216px and proportion 100x90%.
    Haw can I return the old behaviour?
    Second.
    In CS2 I use files with a lot of smart objects each of them may consists with some others smart objects and so on.
    But i can`t use this scheme in CS3-CS5 because of very high consumption of scratch memory.
    Very-very simple example. In CS2 create file 4000x3000px, create new layer and draw there black square 300x300px.
    Convert the "square" layer to smart object. Then duplicate it with Ctlt-J 30 times. Save the file and reopen.
    The scratch size is about 280 MB and practically not changing when moving layers with movetool.
    Open this file in CS5. The scratch size is about 2.5 GB and quickly increase to 5 GB and above when i try to move layers. And this is a very simple file.
    If i will try to open several such files in CS5 the amount of useing memory will be fantastic.
    Why there is such behaviour whis memory in cs3-cs5 photoshops?
    PS. sorry for my english. hope you understand me.

    Hi,
    What version of Ps and AI are you using?
    1. In Ps, there's no controls for the AI layer visibilty, but the visibility attributes should be respected.
    2. The placed file is an embedded copy, not a link to an external file. However, there is a script that you might find useful for your purposes. I'm not sure if the Win support improved with CS5.
    http://ps-scripts.com/bb/viewtopic.php?t=3045%20Brilliant%21%21
    regards,
    steve

  • Question about creating Forms in Java.

    Hello , im new to Java , i find kinda weird how Java creates Forms , its pretty simple in Oracle Forms ,
    why did Java designers make it this difficult ? do people say this is something bad about Java ?
    when i learned about the Layout Managers that Java provides i found out how much code one have to write just to create a simple form ,my question to the experienced java developers : what do you do to create a form , do you hard code it ? , or do you use something like GUI Builder in an IDE like NetBeans for example? and is the code generated by this builder easy to deal with and modify ?
    Thanks ....

    HeavenBoy wrote:
    Hello , im new to Java , i find kinda weird how Java creates Forms , its pretty simple in Oracle Forms ,
    why did Java designers make it this difficult ? do people say this is something bad about Java ?Some Oracle Forms fans certainly do. But the truth is that Oracle Forms application tie down all the components in fixed pixels. The typical Swing form can be resized and can function at different screen resolutions. So, when designing a Java form, we don't tend to work on a fixed grid but define the sizes and positions relative to other components. What's more the interface between the form elements and the data is completely flexible, and flexibility means extra effort.
    >
    when i learned about the Layout Managers that Java provides i found out how much code one have to write just to create a simple form ,my question to the experienced java developers : what do you do to create a form , do you hard code it ? , or do you use something like GUI Builder in an IDE like NetBeans for example? and is the code generated by this builder easy to deal with and modify ?
    Most I've tried have been a bit of a straitjacket, but I've recently been using the latest Netbeans offering and it's pretty good. I think the breakthrough was the introduction of the GroupLayout layout manager. This is a layout manager really designed for WYSIWYG form designers (pretty challenging to use hand coded).
    The way these things work is that the class generated contains some methods which cannot be edited by hand, but you can add any amount of your own code without interfering with the generated code. You hook your own code snippets into the generated code, for example you can select a property of an object, say the model of a JTree, and select "user code", then type in an expression returning the TreeModel you want to use.
    With listeners the designer will generate the method signature etc. but you can edit the body of the listener method.
    However I would always recommend that you hand code a form or two before resorting to on of these editors because it's important you understand the code, even where a designer writes it.

  • Questions about creating a foreign key on a large table

    Hello @ll,
    during a database update I lost a foreign key between two tables. The tables are called werteart and werteartarchiv_pt. Because of its size, werteartarchiv_pt is a partitioned table. The missing foreign key was a constraint on table werteartarchiv_pt referencing werteart.
    Some statistics about the sizes of the mentioned tables:
    werteart 22 MB
    werteartarchiv_pt 223 GB
    werteartarchiv_pt (Index) 243 GB
    I tried to create the foreign key again, but it failed with the following error (Excuses for the german error message):
    sqlplus ORA-00604: Fehler auf rekursiver SQL-Ebene 1
    sqlplus ORA-01652: Temp-Segment kann nicht um 128 in Tablespace TEMPS00 erweitert
    The statement I used:
    alter table werteartarchiv_pt
    add constraint werteartarchiv_pt_fk1
    foreign key (schiene, werteartadresse, merkmale)
    references werteart (schiene, werteartadresse, merkmale)
    on delete cascade
    initially deferred deferrable;
    So the problem seems to be, that Oracle needs a lot of temporary tablespace to generate the foreign key and I do not know how much and why.
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.
    2a) Is it possible to tweak the statement without using the temporary tablespace?
    2b) If it is not possible to avoid the usage of the temporary tablespace, is there a formula how to calculate the needed temporary tablespace?
    3) Is it possible to modify data in the tables while the foreign key is created or is the whole table locked during the process?
    Any help or hint is appreciated.
    Regards,
    Bjoern

    RollinHand wrote:
    My questions now are, and hopefully someone is here, who can answer all or a part of it:
    1) Why does Oracle need temporary tablespace to create the foreign key? The foreign key uses the same columns like the primary key.Because it's validating the data to ensure the foreign key won't be violated. If you had specified ENABLE NOVALIDATE when creating it then the existing data in the table wouldn't need to be checked and the statement should complete instantly (future data added would be checked by the constraint).
    http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/general005.htm
    Search for "Enable Novalidate Constraint State"

  • Question about using objects in SQL query.

    I had posted this question in the SQL/PLSQL forum but I guess nobody took the time to understand exactly what I am asking so I decided to try here hoping to get the answer. So here is the thing:
    I have created generic object type "tree" - the constructor takes as a parameter sql query which returns "node_id" and "parent_node_id" - this is all we need to have a tree. The object has all related to a tree structure member functions and one of them is "oldest_relative" (the tree may not be fully connected - it may be more like a set of many trees, so it's not necessary all nodes to have the same root).
    I also have departments table with the following fields: department_id, parent_department_id, department_name,...
    all records in the table w/out parent_departments (parent_department_id is null) are considered divisions.
    Now if I run the following query:
    SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") "DIVISION_ID" FROM departments
    my question is: Is the tree object created for every row or does Oracle somehow caches the object since the object itself is not changing but only the parameter for the oldest_relative member function.
    The table only has a few hunderd records and I can't see much of a difference in the execution time btw the query above and query like this:
    SELECT "DEPARTMENT_ID", "PARENT_DEPARTMENT_ID", "DEPARTMENT_NAME", b.t.oldest_relative("DEPARTMENT_ID") "DIVISION_ID"
    FROM departments left join (select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') t from dual) b on 1 = 1
    where the object is clearly created just ones. (there is probably a better way to do it instead of this join)
    Pls elaborate
    George

    Not exactly sure what the question is...
    As I understand, you are comparing the following two constructor calls:
    +select..  tree('select department_id "node_id", parent_department_id "parent_node_id" from departments').oldest_relative("DEPARTMENT_ID") ... FROM ...+
    +select tree('select department_id "node_id", parent_department_id "parent_node_id" from departments') ... FROM dual+
    These calls are the same (besides the 1st one doing an immediate implicit call to a method of the object being constructed). The number of times these are being called depends on the number of times this SQL projection is applied - and that is determined by the number of rows being projected by the SELECT.
    The latter one is against DUAL which only has a single row. So that constructor is only called once. The former can be against multiple rows. Obviously a single pass through a data set is desirable - which means that the sub-select (use by the constructor) should ideally only be executed once and makes the 2nd method more desirable.
    However, I'm having a hard time understanding why the class and constructor are at all needed. Why pull data from a SQL table into PL memory? As that is where the class will need to cache and store the results of that construction parameter SQL SELECT. And once in PL memory, how does the object effectively access, search and use this cached data?
    PL memory is expensive. It is not sharable.
    PL data structures are primitive - these cannot be compared to SQL structures in the form of tables and columns that can be stored in a number of physical ways (index tables, hash tables, partitioned tables, clustered tables, etc). Cannot be indexed like SQL structures using B+tree, bitmap, function and other indexing methods. Cannot be sorted, grouped, analysed, filtered, etc like SQL structured data.
    It makes very little sense to read SQL data into a class and then deal with that data, cached in expensive PL memory, using primitive PL structures.
    And the same would be true if Java or C# was used. The best place for data is inside the SQL engine. That is the most superior environment for data. It can processes more data, scale better, perform better and offer more flexibility, than pulling data from it and then crunch that data using PL or Java or C#.

  • Question about "Create Item" page

    Im working on trying to Insert a new item into a Self-Service Web Applications page.
    As part of my research, I have been looking at this doc:
    Oracle® Application Framework
    Personalization Guide
    Release 11i
    Part No. B25439-02
    From:
    http://download.oracle.com/docs/cd/B25516_18/current/acrobat/115fwkpg.pdf
    The document does not seem to go into much detail about how to Insert an item on a page. I also checked the "OA Component Reference" document.
    I checked the online help via "Create Item Page" - e.g.
    http://oursite/pls/PSAT/fndgfm/fnd_help.get/US/FND/CUST_PERSADMIN_CREATEITEM.HTM
    Again, that doesn't give a lot of information.
    As part of my testing / research, I would like to add a new Item to a page, and have the value of the item to be taken from an existing SQL Query.
    For example, in iProcurement, when viewing a Requisition Details, e.g. via this page:
    http://oursite/OA_HTML/OA.jsp?page=/oracle/apps/icx/por/reqmgmt/webui/ReqDetailsPG&reqHeaderId={!!BX6R96mkQOcfNZ60BeTaJQ}&retainAM=Y&addBreadCrumb=Y&_ti=245778094&PersonalizationParam=PersonalizationParamAdmin&oapc=12&oas=mYF7zP1VI7xoAWcUQHTEkQ..
    I would like to add in the "NOTE_TO_AUTHORIZER" field from the "po.po_requisition_headers_all" table.
    From looking at the "About this Page" link, I can see there is a View Object called "oracle.apps.icx.por.reqmgmt.server.ReqHeaderVO".
    This ViewObject contains an Attribute called "NoteToAuthorizer" with a Type of "java.lang.String".
    When I go to the "Create Item" page, and choose and Item Style of "Message Styled Text" there seems to be no way to say which database field you want to include.
    From looking at a previous customisation that a developer did, I can see you can pull in an Attribute via the "View Attribute" field, and link in the VO via the "View Instance" field.
    When inserting database values into a Self-Service page, can we only insert Attributes, and not any of the other regular fields from View Objects?
    Apologies for the rambling essay.
    Any advice much appreciated.
    Thanks

    Hi Jimr,
    In OAF sql queries are represented by View Objects and columns of query will be represented by View Attribute.
    For every column in query there will be corresponding view attribute name, so while adding any item on self service page which represents data from database you need to specify view instance name and view attribute name, which will specify which column and from which query it will show the data.
    *"When I go to the "Create Item" page, I can't work out how to tell Oracle that the Item I want to create should be the "NoteToAuthorizer" field from the "ReqHeaderVO" ViewObject."* so ReqHeaderVO1 will be the instance(by default OAF generates instance like this) and "NoteToAuthorizer" can be mentioned in View Attribute name property.
    Let me know if you need further clarification.
    Regards,
    Reetesh Sharma

  • Some questions about creating web animations with lighter data and exporting to vector Flash format.

    Hi, I will be creating animations in After Effects mostly using Illustrator vector files and will be exporting to SWF or XFL for using the animations on the web.
    One of the priorities is light data as possible to provide viewers with slower connections with better experience. However the animation should also impress and I need to find a balance between performance and possible imagery.  The animations may have sound and voice narrative.
    I need help with understanding which type of non-vector data is heavier than others. Non-vector image data or sound and voice? And from non-vector image data is some of it lighter or heavier than other - for example motion blur vs smooth gradient vs many colors?
    I would greatly appreciate any suggestions, tips, pointers, etc.,

    Hi, I will be creating animations in After Effects mostly using Illustrator vector files and will be exporting to SWF or XFL for using the animations on the web.
    One of the priorities is light data as possible to provide viewers with slower connections with better experience. However the animation should also impress and I need to find a balance between performance and possible imagery.  The animations may have sound and voice narrative.
    I need help with understanding which type of non-vector data is heavier than others. Non-vector image data or sound and voice? And from non-vector image data is some of it lighter or heavier than other - for example motion blur vs smooth gradient vs many colors?
    Let's do a little "Myth Busters" on that one, shall we?
    Vector data is per se not "lighter" than pixel data. You could have complex paths for which storing the information of the individual nodes takes up more space than a pixel image of the object.
    Dynamic rasterization of vector data costs CPU performance and may in effect make things more slow than just playing a series of pixel images. That would apply to anything from path strokes to gradients.
    All your pretty AI vectors don't mean anything if they are constructed in such a way that either AE or Flash need to rasterize them on import. Anything from converting Bezier paths to paths consisting of dense linear segments to converting fills, patterns, gradient meshes and so on to pixel data
    Pixels are pixels. It does not matter whether they are gradients, mothionblur or just non-antialiased shapes. Flash doesn't care and neither image format that may be used in Flash stores any more or less info. They only differ in their methods, but in the end it's for you to decide whether you use JPEG, PNG8 or PNG24. They all have their pros and cons.
    It makes a difference, if data is embedded in an SWF or if it is externally linked just as it makes a difference whether you enforce audio sync or not, playing every frame or not.
    So for all intends and purposes, it's still up to you to make up your own mind and find the best solution. And Rick has a point - if you're really that concerned about efficiency, then do it in Flash or Flash Catalyst and consider the options there that may help like GPU accelerated layer styles for drop shadows etc., dynamic text or your vector data remaining vector in teh first place.
    Mylenium

  • Very Nube Question About Creating a Very Basic Application Bundle / Package

    I don't know anything about XCode or AppleScript, other than that they exist, so I'm coming at this with only conceptual knowledge of how applications on OS-X work. Nonetheless, I have a goal that I feel should be really easy to accomplish, I just don't know where to begin.
    What I have is an html file with an embedded flash project that also references some outside files, such as pdfs for printing. This was designed to live on the web, but in reality it will be shipped out on a CD. Right now, if you insert the cd, you see the file contents (the above mentioned HTML file, as well as two folders containing the flash files and the pdfs that are embedded in or linked out from the html file).
    This isn't very elegant, and doesn't accomplish the "app" feel I'm shooting for. What I'm wondering is: is there a way to create an application package that has the html file and content folders tucked inside of it, so that when a user clicks on the application package, the html file is automatically launched? What resources might you point me to in order to learn how to do this in a relatively short amount of time? (I'm not even positive if I'm using the correct terminology to search for solutions... is it an application package or an application bundle?)
    Now for the limitations:
    These files were generated on a Windows machine by an eLearning tool ("Articulate Presenter") and therefore really can't be fiddled with much. I can't open any of the flash files and change the directory paths for the resource files the main presentation needs. I'm fairly confident the presentation just refers to the folder the html file is in as its root, so if the file structure could stay relatively intact once all the files move inside this "bundle," I think everything will still work.
    The Articulate Presenter folks aren't particularly helpful in solving Mac compatibility issues, so I thought I'd pose my question here. If I'm not being clear, I am happy to add additional details. Thanks very much for your patience with, and willingness to offer advice to, a complete newbie.
    Cheers!

    It's even easier than you think.
    Open AppleScript Editor.
    Type in the following code:
    set htmlFile to (POSIX path of (path to me)) & "Contents/Resources/index.html"
    set openCommand to "open " & quoted form of htmlFile
    do shell script openCommand
    Then do File > Save, and use 'Application' as the file format.
    Then the "Bundle Contents" button on the toolbar will be enabled. Click it to open up the drawer.
    Drag your HTML content and resources into the drawer.
    Do File > Save again. Ta-da, you have your web-content packaged as an application.
    This assumes that the top-level has a file named index.html. If not, modify to suit.

  • Question about Using Objects

    Hi Guys,
    Need some help here with understanding the basics. Basically i'm getting a bit confused on how objects are instantiated and used in java. Firstly an object of a class is instantiated with the following piece of code;
    ClassA obj = new ClassA();This would allow you to use the variable and method of ClassA. Say ClassA has the method set(). You could call it via the obj object with the code;
    obj.set();that I understand. You can also declare an annonymous object which is an object that is only really going to be used once for the purposes of the statement. For example, something like;
    System.out.println(new Date());That I understand too. However what is confusing me is this type of object instantiation;
    public static ClassA obj; You cannot not call the set() method of the ClassA in the same way so why use this? Also this code is confusing me;
    obj = new ClassA();Are you saying that a precreated object is now equal to ClassA. Meaning that you can call its set() method in the same way?
    What do they mean? Why are they used? Can anyone give me an example of how they would be used?
    Any help would be appreciated.

    public static ClassA obj;This is a declaration, basically you are telling the
    computer that you intend to make a "ClassA" object
    and the program will allocate enough memory to hold a
    "ClassA" object, although the object "obj" does not
    actually "exist" at this time. This is why you can't
    use the set() method, because obj doesn't have any
    methods at all since it hasn't fully been created
    yet.
    obj = new ClassA();This is what actually creates the object, according
    to the instructions in the object's "ClassA()"
    method, which is known as a constructor.
    ClassA obj = new ClassA();This statement simply combines the two previous ones
    into one line. You are declaring "obj" to be a
    "ClassA" which allocates memory to store it, and then
    immediately executing the "ClassA()" constructor to
    build a new ClassA and store it in the memory space
    referenced by "obj". Does any of that make sense?
    I'm not exactly a teacher, but I think I understand
    your problem enough to explain it.Yes that does make sense. However i have some more questions now if you dont mind answering.
    If the code
        public static ClassA obj;simply allocates the memory (instantiate) and does not name (declare) the object then why cant you do something like this afterwards;
    obj = new ClassC();or this;
    obj1 = new ClassA();The object doesn't yet exist you only putting memory aside for it. Its only at this point that your naming the object and setting the parameters for it.
    Why bother even allocating memory for the object without actually declaring the object? Surely combing the two statements is more efficient and makes more sense than separating them. Why do you need to allocate the memory and then give it a name?
    Also the following piece of code;
    ClassA objA = obj;Since obj is already intialized as being a new ClassA object, then is this simply declaring and instantiating a new object of type ClassA? And what is the difference between this and;
    ClassA objA = new ClassA();Thank You

Maybe you are looking for

  • Converting a text file into a String

    I need to convert a text file (in whatever format, in my case it would be xml and xsl files) in a String. I made this methods: public static String createStringFromFile(File f) {         StringBuffer buf = new StringBuffer();         try {           

  • I'm trying to watch itv player but it won't let me keeps saying only available in the uk

    Can anyone help me please I'm trying to watch itv player and it won't let me keeps saying only available in the uk and I am in the uk

  • Computer's Short Name

    I want to change my computer's "shortname" (the name that appears at the top of the finder) but I dont know how. Can anyone tell me?

  • List Of SAP Implemented Companies.

    Hi, Can Someone tell me the list of SAP Implemented Companies in Delhi ncr. Thanks in advance. Regards, Anamika Sharma.

  • Quiet line test has mains hum - how to fix

    My BT incoming pair is located right below the electrical mains distribution board. A Quiet line test has main hum which goes away when I trip the RCDs (there are two) My speed has never been good (2.5Mb max - we are nearly in the next exchange area)