List < object > or just what is the best?

Hi guys,.
List<Object> list1 = new ArrayList<Object>();
List list2 = new ArrayList();
Logically speaking, the two sounds similar. But what is the best to use?

I can do something like
list1 = list2;
OR
list2 = list1;
But if
List<String> list3 = new ArrayList<String>();
Why can't I just do this
list1 = list3; // throws compilation error 
Thank you
javaCrazy

List and list are similar, but are different. Try to replace the list list and see what happens.
The reason is not so intuitive is explained in the section generic generic tutorial, where, if I remember correctly, they explain why a list is not a list.
This is why a list of is not alist, but it's a list.

Published by: baftos on October 14, 2011 08:20

Tags: Java

Similar Questions

  • What is the best way to the list of members in trouble?

    We have Calcs this list to a month in the following way.  What is the best, or isn't it important?

    FIX (@CHILD ("QTR1"), @CHILD("QTR2"), @CHILD("QTR3"), @CHILD ("QTR4"))

    Fix("Jan":"Dec")

    FIX (@CHILDREN ("QTR1"), @CHILDREN("QTR2"), @CHILDREN("QTR3"), @CHILDREN ("QTR4"))

    I'll tell you which is worse:

    With the help of @CHILD, because @CHILD is not the name of a documented calculator function.  It's @CHILDREN.  @CHILD works because (at least in some cases) Essbase will include function truncated names.  Of course, if you get short enough that the truncated version is ambiguous, it will not - @CUR could be @CURLEV, @CURGEN, @CURRMBR, or @CURRMBRRANGE.  My opinion is that this behavior is a bad habit and just ask to make your code in the future break free when a new function appears and makes the ambiguous short form.

    I can't think of a good reason to prefer the @CHILDREN of each quarter 'Jan': 'Dec' with a dimension of time (unlikely to change). It is short and readable immediately.

    If you do not have other leaf-level members in the time dimension there are other options too (see @LEVMBRS, for example).

  • What is the best way to save an array of objects and then load it?

    Hi, what is the best way to save and load an array of objects?

    I hade a code like that, but it does not work:

    var test = new Array();
    test.push(new Foo("a"));
    for (var i = 0; i < test.length; i++) {
        console.log(test[i]);
    }
    // save and load, then show again
    localStorage.setItem("test", test);
    var test2 = localStorage("test");
    for (var i = 0; i < test2.length; i++) {
        console.log(test2[i]);
    }
    

    the problem is, the first newspaper that get the things I want. The second time I get:

    Uncaught TypeError: Property 'localStorage' of object [object Object] is not a function
    

    The work around this problem is to stringify before saving and then analyze before loading.

    http://StackOverflow.com/a/2010948/773263

    Although I said, it is better to use IndexDB.

  • Just ordered new MacBook Pro. What is the best way to transfer Photoshop, InDesign

    I just ordered new MacBook Pro. I need to transfer files and applications from my old to my new MacBook.  What is the best way to do this with the least time involved? I have our serial numbers for Photoshop and InDesign available group license.

    Thank you

    Please see CS5 download products

    Hope that helps!

  • DPS: Judge to use the parameter Raster or vector in the States of the objects when the majority of the page is a photo. What is the best setting for the overall performance?

    I am trying to decide whether to use the parameter Raster or vector in the States of the object when the majority of the screen is a picture (with a modest but important legend for children to read). The legend certainly makes it look more net as vector. But does the photo! The raster setting seems to make the lower-res images in comparison. In my first edition of my application, I thought that raster would be the best setting when the photo was the subject dominating the page. But now, after seeing how strong he looks like vector, (but with almost a refresh of the unacceptable time. Perhaps better on the latest iPad. Most of my readers/students in class will use iPad 2 s, which has a slower processor). I wonder if I should go through the trouble of changing States of photo objects that have the type as well to the vector. It doesn't seem to be as sensitive to a re - draw on the iPad 2 (non-retine)

    Is Filesize hit if I make about 1200 on these objects range from Raster to vector? (It is a huge, highly interactive history book, so I'm curious if acutally go to vector on these photos would reduce the size of the file) What is the best setting for the overall performance?

    I see the freeks screen outside for a bit if you try to pinch and zoom in a vector object (photo) vs raster. Which is disappointing. Does slow down load time/refreshment in frame, which is a little less. I also found that the drop shadows really bad that redraws effect in vector, almost vibrating in a slide show, for example. Thus, in cases where I need shadows, I'm sticking with Raster.

    All tips go ahead?

    Brian

    Does that help? http://boblevine.us/Digital-Publishing-Suite-101-keep-text-sharp-in-raster-slideshows/

  • What is the best way to show 1000 objects moving in a field?

    Hello. I'm trying to JavaFX 2.0 and higher. I want to create 1000 objects (because now they can be rectangles) and move them randomly (for now). What is the best way to do this? Do I have to create an initial keyframe for each object? I was watching the demo of BrickBreaker. Is all that I need? I'm looking for a simple example. For example: ColorfulCirclesSample. Basically, what I want to do is create 1000 rectangles with random attributes including a vector (direction and speed) and show them using JavaFX 2.x.

    Thanks in advance.

    ServandoC

    Not that this is the best way, but it's an example, you can try:

    import java.util.Random;
    import javafx.animation.*;
    import javafx.application.Application;
    import javafx.event.*;
    import javafx.scene.*;
    import javafx.scene.image.*;
    import javafx.scene.input.KeyEvent;
    import javafx.scene.paint.Color;
    import javafx.scene.transform.Rotate;
    import javafx.stage.Screen;
    import javafx.stage.Stage;
    import javafx.util.Duration;
    
    // animates a 1000 objects (klingons) moving around the scene at random directions and velocity.
    public class ObjectsInMotion extends Application {
      private static Random random = new Random(42);
      private static final int    N_OBJECTS   = 1000;
      private static final int    OBJECT_SIZE = 20;
      private static final Image  KLINGON = new Image("http://icons.mysitemyway.com/wp-content/gallery/green-jelly-icons-transport-travel/038998-green-jelly-icon-transport-travel-star-trek-sc43.png", OBJECT_SIZE, OBJECT_SIZE, true, true);
      public static void main(String[] args) { launch(args); }
      @Override public void start(final Stage stage) throws Exception {
        // initialize the stage to fill the screen with klingons.
        stage.setTitle("Starboard bow");
        stage.setFullScreen(true);
        final double screenWidth    = Screen.getPrimary().getBounds().getWidth();
        final double screenHeight   = Screen.getPrimary().getBounds().getHeight();
        final Group objects = new Group(constructObjects(N_OBJECTS, OBJECT_SIZE, (int) screenWidth, (int) screenHeight));
        stage.setScene(new Scene(objects, screenWidth, screenHeight, Color.MIDNIGHTBLUE.darker().darker().darker()));
        stage.show();
    
        // press any key to exit the program.
        stage.getScene().setOnKeyTyped(new EventHandler() {
          @Override public void handle(KeyEvent event) {
            stage.close();
          }
        });
    
        // move the klingons around according to their motion vectors.
        final Timeline timeline = new Timeline(
          new KeyFrame(
            new Duration(1000/30), // update the klingon's motion 30 times a second.
            new EventHandler() {
              @Override public void handle(ActionEvent event) {
                for (Node n: objects.getChildren()) {
                  // apply the motion vector for this object to determine the object's new location.
                  MotionVector vector = (MotionVector) n.getUserData();
                  double tx = n.getTranslateX() + vector.velocity * Math.cos(Math.toRadians(vector.angle));
                  double ty = n.getTranslateY() + vector.velocity * Math.sin(Math.toRadians(vector.angle));
    
                  // wrap the objects around when they fall off the starfield.
                  if (tx + n.getLayoutX() > screenWidth)  tx -= screenWidth;
                  if (tx + n.getLayoutX() < 0)            tx += screenWidth;
                  if (ty + n.getLayoutY() > screenHeight) ty -= screenHeight;
                  if (ty + n.getLayoutY() < 0)            ty += screenHeight;
    
                  // update the object co-ordinates.
                  n.setTranslateX(tx);
                  n.setTranslateY(ty);
                }
              }
            }
          )
        );
        timeline.setRate(5);
        timeline.getCurrentRate();
        timeline.setCycleCount(Animation.INDEFINITE);
        timeline.play();
      }
    
      // construct an array of n objects of rectangular size spaced randomly within a field of width and height.
      private Node[] constructObjects(final int n, final int size, final int width, final int height) {
        Node[] nodes = new Node[n];
        for (int i = 0; i < n; i++) {
          ImageView node = new ImageView(KLINGON);
          node.setLayoutX(random.nextInt(width  - size / 2));
          node.setLayoutY(random.nextInt(height - size / 2));
          MotionVector vector = new MotionVector();
          node.setUserData(vector);
          // rotate the klingon to align with the motion vector accounting for the klingon image initially pointing south-west.
          node.getTransforms().add(new Rotate(vector.angle + 225, node.getFitWidth() / 2, node.getFitHeight() / 2));
          nodes[i] = node;
        }
    
        return nodes;
      }
    
      // polar co-ordinates of a motion vector.
      class MotionVector {
        final double velocity = random.nextDouble();
        final double angle    = random.nextDouble() * 360;
      }
    }
    
  • Just bought a new Apple computer. What is the best way to transfer the CS6 and Lightroom

    Just bought a new Apple computer. What is the best way to transer CS6 and Lightroom? Both applications have been updated. Should I reinstall it on the Adobe site?

    first of all, if you're going to retire this old computer or, at least, no longer use your adobe on this old computer programs, open and click Help > deactivate.

    then install your files to your new computer and activate.  If you already have an installation cd, you don't need to download.  If you don't have the installation files, download the trial and activate it with your order number.

  • What is the best way to deal with a 'Implicit coercion' in a table to a sprite?

    Hi all!

    With the continued support of this forum, I'm getting closer to have a programme of work. I can't wait to be able to help others like me once I've finished learning the ropes of AS3.

    I'll briefly explain what I want to achieve and then followed with my question.

    Background

    I created a random number of 12 x 9 grid that fills each cell with an image, based on the numeric value of each cell. I also have a random play button that makes random numbers in the grid. The problem I am running became my click event of button to erase the current images off the grid in order to allocate the new (for example by removing the objects display battery in order to place the new ones in the same places).

    Question

    My question is this: what is the best way to manage an implicit constraint from a table to a sprite? I pasted my complete code below so that you can see how the functions are supposed to work together. My sentence is apparently not being able to use a value from array with a sprite (sprite represents the real layout of the grid on the pile of display while the table starts as a number that is assigned an image that must be transmitted to the sprite).

    ============================================================================

    package
    {
    import flash.display.MovieClip;
    import flash.display.DisplayObject;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.getDefinitionByName;

    SerializableAttribute public class extends MovieClip Blanko
    {
    Contains 12 * 9 grid of cells.
    var grid: Sprite;
    Maintains the shuffle button.
    var shuffleButton:Sprite;
    Is equal to 12 columns, 9 lines.
    var cols: int = 12;
    lines of the var: int = 9;
    Equal number of grid cells (108).
    cells var: int = COL * rows;
    Sets of cell width and height to 40 pixels.
    var cellW:int = 40;
    var cellH:int = 40;
    Contains 108 images of cell.
    var imageArray:Array = [];
    Contains 108 numerical values for the cells in the grid.
    var cellNumbers:Array = [];

    Constructor calls the functions "generateGrid" and "makeShuffleButton".
    public void Blanko()
    {
    generateGrid();
    makeShuffleButton();
    }

    Creates and displays the grid 12 * 9.
    private function generateGrid (): void
    {
    grid = new Sprite;
    var i: int = 0;


    for (i = 0; i < cells; i ++)
    {
    cellNumbers.push (i % 9 + 1);
    }
    trace ("before shuffle:", cellNumbers);
    shuffleCells (cellNumbers);
    trace ("after shuffle:", cellNumbers);
    var _cell:Sprite;

    for (i = 0; i < cells; i ++)
    {

    / / This line is where the implicit constraint occurs. '_cell' is a leprechaun trying

    on a temporary basis equal to a value from array.
    _cell = drawCells (cellNumbers [i]);
    _cell.x = (I % cols) * cellW;
    _cell.y = (I / COL) * cellH;

    grid.addChild (_cell);
    }
    }

    Creates a "shuffle" button and adds a mouse click event.
    private function makeShuffleButton (): void
    {
    var _label:TextField = new TextField();
    _label. AutoSize = 'center ';
    TextField (_label) .multiline = TextField (_label) .wordWrap = false;
    TextField (_label) .defaultTextFormat is new TextFormat ("Arial", 11, 0xFFFFFF, "bold");.
    _label. Text = "SHUFFLE";
    _label.x = 4;
    _label.y = 2;
    shuffleButton = new Sprite();
    shuffleButton.graphics.beginFill (0 x 484848);
    shuffleButton.graphics.drawRoundRect (0, 0, _label.width + _label.x * 2, _label.height +)
    _label.y * 2, 10);
    shuffleButton.addChild (_label);
    shuffleButton.buttonMode = shuffleButton.useHandCursor = true;
    shuffleButton.mouseChildren = false;
    shuffleButton.x = grid.x + 30 + grid.width - shuffleButton.width;
    shuffleButton.y = grid.y + grid.height + 10;
    this.addChild (shuffleButton);
    shuffleButton.addEventListener (MouseEvent.CLICK, onShuffleButtonClick);
    }

    Erase the images of the cell, mix of their numbers and then assigned these new images.
    private function onShuffleButtonClick (): void
    {
    eraseCells();
    shuffleCells (cellNumbers);
    trace ("after shuffle:", cellNumbers);


    for (var i: int = 0; i < cells; i ++)
    {
    drawCells (cellNumbers [i]);
    }
    }

    Deletes any existing cells in the battery of the display image.
    private void eraseCells(): void
    {
    While (imageArray.numChildren > 0)
    {
    imageArray.removeChildAt (0);
    }
    }

    Changes cell phones numbers (makes random table).
    private void shuffleCells(_array:Array):void
    {
    var _number:int = 0;
    var _a:int = 0;
    var _b:int = 0;
    var _rand:int = 0;

    for (var i: int = _array.length - 1; i > 0; i-)
    {
    _rand = Math.Random () * (i - 1);
    _A = _array [i];
    _B = _array [_rand];
    _ARRAY [i] = _b;
    [_Rand] _ARRAY = _a;
    }
    }

    Retrieves and sets a custom image to a cell based on its numerical value.
    private void drawCells(_numeral:int):Array
    {
    var _classRef: Class = Class (getDefinitionByName ("skin" + _numeral));
    _classRef.x = 30;
    imageArray.push (_classRef);
    imageArray.addChild (_classRef);
    return of demonstration;
    }
    }
    }

    ===========================================================================

    Any help with this is greatly appreciated. Thank you!

    If you want to have an array of Sprites that you later clear that is fine. But this does not mean that your function should return to it.

    You need your function to return the sprite so that you can add it to the display list and everything what you need.

    So just have the function get Sprite, push it in the "toBeClearedInTheFutureArray" and then return a reference to the currently acquired sprite.

  • What is the best way to move and organize records

    I recently bought a Mac Pro and have bought files across the FRO my windows laptop but what is the best way to organize the files iCloud or local drive and how do I move files in my list of "all files" in individual cases.

    In case you are not aware, all the files that you put in iCloud drive are on your disk local and iCloud.

    You can go to preferences in the Finder menu and specify whether you want iCloud drive to display in the sidebar of the Finder. I find that having it in the sidebar makes it easy to use. I also have other folders I used frequently in the sidebar; You can add the system ones (Documents, downloads, etc.) using this same preferences window. You can add folders that you created them by dragging to the sidebar of a Finder window.

    A way to move files into folders that you created is to open 2 windows in the Finder and drag it from one window to the other. Another option, if you move a file in one of the folders that is displayed in the sidebar is just do it from its current location in the main area of the Finder to the folder window in the sidebar in this same window of Finder.

  • What is the best version of Windows 7 Ultimate to buy?

    I have another question: I'm looking for all versions of Windows 7 Ultimate edition (I'm addicted to this software), but it is quite confusing to know which one is the best for what I'm doing or simply, what is the best in general. Some mention a GLC as the MFN (?), some say that it is an OEM some just call it a retail version full version which has SP1. I had 3 different versions of Ultimate on my laptop (I can't say which ones, but they reacted differently) where all turns be fake/false, (very, very bad luck) so before we get through all this again with the re * loading the software, I want to make a decision because on who is who. It's just hard to say which is best. I really put my laptop to his test for everything. I have about 3ooo images, so I do a lot with photography, play the games, many commuunications & helping with my husband's company. It is therefore a very wide varitey of uses.

    Thanks for all your help, it is greatly appreciated! JD

    P.S. I definatley want to Windows 7 Ultimate.

    You don't need the final version to accomplish the tasks listed. Family Premium would do the job very well and you would save $$$.

    What you get, do NOT buy on auctions, Amazon or classifieds sites.

    Back, save, copy all your important stuff on a disk external hard and then start again with your newly acquired operating system...

  • What are the best practices for a new employee to learn inside the instance of their business of Eloqua as efficiently as possible?

    We have companies everything changed at some point in our lives. And we all go through the process in the first weeks, where you feel new and are just trying to figure out how not to get lost on your way in the mornings.

    On top of that, trying to familiarize yourself with your new company Eloqua instance can be a daunting task, especially if it's a large organization.

    What are the best practices for new employees to learn as efficiently and effectively as possible?

    I am in this situation right now. Moved to a much larger organization. It is a huge task trying to understand all the ins and outs not only society, but also of the eloqua instance, especially when she is complex with many points of integration. I find that most of the learning happens when I really go do the work. I spent a ton of time going through the programs, documentation, integrations, etc., but after awhile, it's all just words on a page and not absorbed.

    The biggest thing that I recommend is to learn how and why things are made the way they are currently, ask lots of questions, don't assume not that things work the same as they did with your previous employer.

    Download some base in place level benchmarks to demonstrate additional improvement.

    Make a list of tasks in the long term. As a new pair of eyes, make a list of things you'd like to improve.

  • What is the best technology side server for JavaFX?

    Hello

    I have a Java EE application server want to communicate with customer JavaFX. What is the best technology to do this? I used the Web Service to Exchange before JSon data. But the performance is a problem and need more code to convert JSon to Java.

    What is the best depends on opinion, your application and your experience.

    Tech in general server-side is also a fairly large area, even if focus me only on the communication technology.

    • The use of web sockets on the client and server would be an option (it is part of JEE7 and you can include the libraries of customer specific web socket with your client application in JavaFX).  Web Sockets simply provide a transport mechanism, so you must always define your own protocol format and communication of serialization to sit on top of the raw web decision-making.  You can use stuff like JMS and STOMP on web socketsand pair it with that Jackson serialized JSON objects, but it is overkill for many applications.
    • Stick to something a little more proven as JAX-RS is bigger than the web use of sockets and you'll probably find examples more and have fewer teeth problems.
    • Things like Hessian binary formats are surprisingly simple to work with.
    • Akka is quite a system ordered, although it is not part of Java EE, it's a good choice if your application is basic Scala.  You can use it with Java, but I just like playing with it works better with Scala.

    In short, I guess, a lot of options.

    > performance is an issue

    It's a little surprising, performance is usually not a problem for this kind of technology unless you are dealing with large scale, often people make too big a deal out of it IMO.  Generally, it's things like the number of roundtrips, the network latency and performance of Access database including most impacts network performance.

  • What is the best way to download icons I created on illustrator on a file photoshop of a Web site design?

    I currently trying to design a website on Photoshop. I designed a few icons for the Web site using Illustrator. What is the best way to download these icons on the photoshop file and keep them looking for crisp and high quality? I tried a number of ways, but all seem to come out pixelated.

    What you need to do is to ensure that you create the icons the PPIS and the Photoshop document Illustrator and true to size. If you have created the icons tell with 300ppi, but are in pixels it do not have the same properties that the Web site that you create if that was put in place as 72 dpi and so will distort.

    Once you have mastered that you are better (if you think that there may be changes to the icons later down the line) to create each icon .ai files and place them intt the Photoshop document, and then if you make changes to the source .ai file that it will update in the design of Web sites you.

    If you see no icons change then you can always just copy and paste directly from Illustrator, Photoshop and make changes on the fly, ensuring that keep you it as a smart object.

  • What is the best way to move the data from the app and Server data structures?

    Hi guys,.

    I developed my application locally with Apex 4.2 and Oracle 11 g XE on Windows 7. Not far away, it is time to move the application to a server Oracle Apex. I guess that Exim is the way to go app. But what about the APA tables and data (tables/as 'customer' and 'account' created specially for the application)? I've been using a modeling tool, so I can run a DDL script to create the database server data structures. What is the best way to move the application data on the server? Is it possible to move the structures and data in a single process?

    Thank you
    Kim

    There is probably another way to get here, but in Developer SQL, on the navigation tree, expand objects until your table, right-click, and then click EXPORT... you will see all the options. It is a tedious process and it sucks IMO, but yes, it works. This is zero especially because 1) it's a table at a time, 2) If your data model is robust and has constraints and sequences and triggers, then you will need to disable all for the insert and we hope you can re-enable constraints, etc. without hitch (good luck, unless you have only a handful of tables)

    I prefer to use the oracle EXP command-line to export an entire schema, then the server target, I use IMP to import the schema. In this way, it is almost true. This makes the dirty life if you develop multiple applications in a single schema, and I felt pain - however - it is much easier to drop the tables and other objects is to create them! (thus, even if the process of EXP/IMP moved more than you wanted to "move".. blow everything you don't want on the target after the fact...)

    You can use method datapump oracle too.

    If not, what can be done, IF you have access to both servers of your instance of SQL developer (or if you can tnsping both already from the command line, you can use SQL * MORE), is to run a script that will identify the objects of your applications apex (usually by the prefix for the names of objects, such as % EBA_PROJ_ etc.) and do all the manual work for you. I've created a script that does just that so that I can pass data from dev to prod servers on a dblink. It is difficult because of the order that must be executed to disable constraints and then turn it back on and of course, more complicated if don't always precede you ALL your "objects demand '... (tables, views, triggers, sequences, functions, procs, indexes, etc.)

  • What is the best way to import and export images from the 5 d Mark II?

    Hello

    I have just finished what I plan my first masterpiece of shooting film.  Shot on the Canon 5 d (1080 p, 24 fps), and the film looks amazing.  Now, I'm ready to start editing and now use creating lately, but I still have to figure out the proper conduct.  I want to know the best way to keep the resolution before I dive into this project.

    My questions:

    (1) what is the best way to start a new project and import the images without having to make while editing, in order to keep all the resolution and the originality of the source footage?

    (2) what is the best way / codec / format to export these images even once done editing to maintain than crisp 1080 p for which the 5 d is therefore counted?

    (3) what is the best way / codec / format for import and export / rendering between the first and after effects?  I speak especially of Visual effects and color correction.  I also a few sequences of 30 images per second that I intend to slow down in AE and then import into first.

    I know that it's wide enough, but as a solo Director I really need advice from someone.  Rarely, I finished my films with the same look crispy as images.  I need help of pipeline and really appreciate it!

    > used first lately

    A list of tutorial in the #3 http://forums.adobe.com/message/2276578 message

    1 - Please NOTE that the PPro CS6 screen may be a little different (I use CS5)

    For CS5 and later versions, the easy way to ensure that your video and your project

    See 2nd post for the photo of a NEW ELEMENT of process http://forums.adobe.com/thread/872666

    - and a FAQ on setting http://forums.adobe.com/message/3804341 sequence

    2 - BluRay... but I'm not sure if 1080 p is supported (I don't use of BluRay)

    1080 p http://forums.adobe.com/thread/995191 some work, some are not

    In addition, for upcoming posts, information FAQ http://forums.adobe.com/message/4200840

    In addition, read the metadata contained in the file http://forums.adobe.com/thread/1015001?tstart=0

    And finally, read Bill Hunt on http://forums.adobe.com/thread/919388?tstart=0 installation project

Maybe you are looking for