About 814,000 results
Open links in new tab
  1. java - Immutable class? - Stack Overflow

    Jul 2, 2010 · How can one make a Java class immutable? From JDK 14+ which has JEP 359, we can use "records". It is the simplest and hustle free way of creating Immutable class. A record …

  2. java - How can I make my class iterable so I can use foreach syntax ...

    Feb 2, 2014 · For making a class iteratable you need to implement Iterable Interface. a) Declare the class as below. public class BookList implements Iterable<Book> b) Override the iterator() …

  3. How to create a custom exception type in Java? [duplicate]

    There is 1) creating a custom exception type/class (as shown so many times) and 2) raising the exception. To raise an exception, simply pass the appropriate instance to throw , normally: …

  4. java - How to write a Unit Test? - Stack Overflow

    3- In the right package in the test directory, you need to create a Java class (I suggest to use Test.java). 4- In the created class, type '@Test'. Then, among the options that IntelliJ gives …

  5. How to create immutable class in java - Stack Overflow

    Dec 25, 2013 · As of Java 16, we can use the records feature (also previewed in Java 14, and previewed in Java 15). Using record is the simplest, hassle-free way of creating Immutable …

  6. reflection - How to solve InaccessibleObjectException ("Unable to …

    Apr 7, 2017 · This exception occurs in a wide variety of scenarios when running an application on Java 9. Certain libraries and frameworks (Spring, Hibernate, JAXB) are particularly prone to it.

  7. immutability - Make immutable Java object - Stack Overflow

    Here are few rules, which helps to make a class immutable in Java : 1. State of immutable object can not be modified after construction, any modification should result in new immutable object. …

  8. How do you define a class of constants in Java? - Stack Overflow

    Having a 'bag of constants' class/interface isn't really following OO best practices. I, and everyone else, ignore #1 from time to time. If you're going to do that then: 2) final class with private …

  9. Making a Java Makefile - Stack Overflow

    Mar 22, 2015 · Using make with java can be an exercise in driving screws with a hammer as soon as you have more than one class. Working java code will use packages. So you'll have a …

  10. How to declare a constant in Java? - Stack Overflow

    Oct 9, 2012 · You can use an enum type in Java 5 and onwards for the purpose you have described. It is type safe. A is an instance variable. (If it has the static modifier, then it …

Refresh