Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!
Score of 3
0 answers
141 views

In a corporate project, I’m migrating from Spring 3.x to Spring 4.x, and also from Jackson 2.x to 3.x at the same time. I do have the following problem: with Jackson 2 this code works "as is"...
Score of 2
1 answer
180 views

Consider the following code: public class Example { static { System.out.println(Example.value); } static final int value = 7; public static void main(final String[] args) { } } ...
Score of 4
3 answers
894 views

This used to be easy in Java 8 and I want to know if it's still possible in Java 21. I've seen a bunch of old posts, all giving different methods for this, none of which worked. I'm hoping for a ...
Score of 2
1 answer
2813 views

First of all, I am a beginner in programming, so please don't expect me to now a lot about this. I am working on a project for my programming course in computer science, where we use JUnit for tests ...
Score of 2
1 answer
313 views

The methods or classes in Kotlin are final by default. But when I mark a method in a Service class to be @Transactional, I realised the service class and all its methods are open. Because for the @...
Score of 0
1 answer
94 views

I have a class with two different final variables and two different constructors. public class Parent { private final String name; private final String dob; public Parent() { ...
Score of 0
1 answer
60 views

I was attempting to test a simple piece of code involving multiplying the constant name by 20 however I noticed I had issues when I entered this code with constants: void test() { const String name ...
Score of 4
1 answer
163 views

A base class in C++ should have at least a virtual destructor, if I inherit from the class. Therefore, one should e.g. better not inherit from std::optional. The answer here says If it doesn't have ...
Score of 0
1 answer
78 views

I have the problem that my getDeclaredField can't find my field, and I can't find why. Any ideas? public interface MapInterface<K extends Comparable<K>, V> { public void setValue(K ...
Score of 2
2 answers
99 views

I'd like to be able to differentiate at runtime (presumably using reflection), between these two cases, where the former has a final field defined at initialization (i.e. a constant), and the latter ...
Score of 6
0 answers
95 views

I have a hierarchy of polymorphic classes. At some level in the hierarchy, I want to make the implementation of a virtual method final. Additionally, I just want to use the base class implementation. ...
Score of 3
2 answers
132 views

I have the following class: public class FileId { final long length; final String hash; FileId(File file) { assert !file.isDirectory(); this.length = file.length(); ...
Score of 0
2 answers
82 views

In the Dart documentation, it states that we should not place const before initializing a const constructor, as the keyword is already implicit. However, can someone explain why the following codes ...
Score of 1
1 answer
286 views

I really enjoy how in Java, we can declare variables "final" within methods to indicate that they will not change after initialization. In C#, you cannot do this same thing-- the only ...
Score of 2
1 answer
132 views

I am facing an issue while using R8 in my Android project. It seems that all the override methods in my code are automatically being converted into final methods. This behavior is causing problems as ...

15 30 50 per page
1
2 3 4 5
112