Skip to content
Advertisement

Tag: static

Java OOP; creating array of objects

I’d like to create an array of objects where 3 objects are from one class, and a 4th is from second class. In the first class I did the following: in the second class I did the following: In the main class, I created several pupil objects and one tutor object, like this: Using objects for printing in main works

Flink ElasticsearchSinkFunction not serializable in non-static method, but serializable in static method

I have a piece of code that only works inside static methods. If I put the code in a static method, then call it from a non-static method, it works. Never heard of anything like this and couldn’t find information online on it. This works: This doesn’t work: (Full) stack trace: The implementation of the provided ElasticsearchSinkFunction is not serializable.

Using static methods with Spring Security to get current user details

I have a requirement to get the details of the current user who has been loggedIn. To get the details, we can use the SecurityContextHolder.getContext() and extract the details. According to, SecurityContextHolder, SecurityContext and Authentication Objects By default, the SecurityContextHolder uses a ThreadLocal to store these details, which means that the security context is always available to methods in the

Advertisement