About 95,000 results
Open links in new tab
  1. Create instance of generic type in Java? - Stack Overflow

    Sep 17, 2008 · Totally wrong: Exception in thread "main" java.lang.ClassCastException: java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType – Aubin Commented Jan 3, 2013 at 19:51

  2. java - Creating an instance using the class name and calling ...

    Is there a way to create an instance of a particular class given the class name (dynamic) and pass parameters to its constructor. Something like: Object object = createInstance("mypackage.MyClass","MyAttributeValue");

  3. oop - What exactly is an instance in Java? - Stack Overflow

    Feb 26, 2011 · For the most part, you use the class merely to create instances and then work with those instances. -Definition taken from the book "Sams Teach Yourself Java in 21 days". Say you have 2 Classes, public class MainClass and public class Class_2 and you want to make an instance of Class_2 in MainClass. This is a very simple and basic way to do it:

  4. java - what is meaning of instance in programming ... - Stack …

    Dec 9, 2021 · An object may be varied in a number of ways. Each realized variation of that object is an instance. The creation of a realized instance is called instantiation. Each time a program runs, it is an instance of that program. In languages that create objects from classes, an object is an instantiation of a class.

  5. Using reflection in Java to create a new instance with the reference ...

    Dec 5, 2012 · Thats how i solved the need to retrieve information to create a new instance from an unknown class to use its fields for another generic search (by field / value and or filters). Forget the "performance" comment, it has something to do with a few lines after these.

  6. java - How to create an instance of an annotation - Stack Overflow

    @john16384 This is to emulate Java's own APIs as closely as possible, for better or worse. But in hindsight, it may not have been the best idea, since this method serves vastly different scenarios from Java's internal annotation factory. I might change it in the next release. –

  7. How create Date Object with values in java - Stack Overflow

    Feb 11, 2014 · Hibernate 5 & JPA 2.2 support java.time. Where to obtain the java.time classes? Java SE 8, Java SE 9, Java SE 10, Java SE 11, and later - Part of the standard Java API with a bundled implementation. Java 9 brought some minor features and fixes. Java SE 6 and Java SE 7. Most of the java.time functionality is back-ported to Java 6 & 7 in ThreeTen ...

  8. Java - How to create new Entry (key, value) - Stack Overflow

    Jun 24, 2010 · Starting from Java 9, there is a new utility method allowing to create an immutable entry which is Map#entry(Object, Object). Here is a simple example: Entry<String, String> entry = Map.entry("foo", "bar"); As it is immutable, calling setValue will throw an UnsupportedOperationException.

  9. Can we create an instance of an interface in Java? [duplicate]

    in the above example we have not instantiated an object of ProgrammerInterview but what we have done is we used ProgrammerInterview to create reference and then created an object of anonymous class. This anonymous class implemented ProgrammerInterview and created object of the anonymous class in one go.

  10. Java inner class and static nested class - Stack Overflow

    Sep 16, 2008 · You also don't need any instance of Outer class to create instance of nested static class in Java. 1) It can access static data members of outer class including private. 2) Static nested class cannot access non-static (instance) data member or method.

Refresh