About 272,000 results
Open links in new tab
  1. What does the 'new' keyword actually do in Java, and should I avoid ...

    The new keyword does exactly what it says on the tin, it creates a brand new object, irrespective of whether one already exists. It creates a new object and stuffs the reference to that object inside the …

  2. When is the appropriate time to use the 'new' keyword?

    24 When is it necessary to use the new keyword in Java. I know you are supposed to use it when you create an instance of an object like this:

  3. java - What does the `new` keyword do? - Stack Overflow

    Dec 18, 2012 · The new keyword in Java creates a new object. In this case it is creating an array ... which is an object. Those two forms are equivalent. The second one is just a convenient shorthand …

  4. How exactly does the 'new' keyword and constructors work

    Sep 13, 2014 · 0 Ok, so i'm study for my first java certification and i can't quite understand exactly what happens underneath the hood when an object is created, some explanations that iv'e read states …

  5. What is the 'new' keyword in JavaScript? - Stack Overflow

    The new keyword is for creating new object instances. And yes, JavaScript is a dynamic programming language, which supports the object-oriented programming paradigm.

  6. Role of new keyword in Java - Stack Overflow

    Jun 5, 2013 · I am not sure how new keyword behaves in Java. Is it for sure that every time I will use new keyword, a new Object will be created on heap? I got this doubt when I was studying following …

  7. What are all the different ways to create an object in Java?

    ObjectInputStream in = new ObjectInputStream(new FileInputStream("data.obj")); Employee emp5 = (Employee) in.readObject(); First three methods new keyword and both newInstance() include a …

  8. new operator - Why does Java require "new" when it is understood …

    Dec 17, 2023 · I've surfed the web for the Java use of "new", and it is for creating a brand new class instance. Why does that require explicit indication via the "new" keyword? Isn't it understood that a …

  9. Benefits of Avoiding 'new' Keword When Creating Object in Java

    Dec 19, 2014 · I have found some blog where there is a suggestion of avoiding new keyword while creating object of a class. Some examples of creating object without the new keyword are- …

  10. java - What is the difference between "text" and new String ("text ...

    Jun 16, 2010 · new String("text"); explicitly creates a new and referentially distinct instance of a String object; String s = "text"; may reuse an instance from the string constant pool if one is available. You …