Source Code
197 subscribers
30 photos
3 files
80 links
Download Telegram
You have an interface(Clickable) with the default click() method, and the class that implements it(Mouse). How to call the default interface method from the implemented click method?
Anonymous Quiz
22%
Clickable.super.click()
24%
Clickable.click()
37%
super.click()
17%
Mouse.super().click()
Result of the main method will be
Anonymous Poll
45%
false
24%
true
24%
compilation error
7%
runtime error
#java StreamAPI
We have a source - our collection. We don't copy all the elements at once, but stretch it, loading the elements in stages, doing some operations.

It's like a file stream, only instead of reading byte by byte, we get references to objects[1] (if we don't have a primitive stream - IntStream, etc.)

Therefore, when the stream is open (we are working with the address space of our data structure), we cannot change it.

[1]By the way, this is a stream of object references, not a stream of bytes. It means we can modify objects of the collection by reference(setters, getters, and so on).

That is, if we had a collection with objects of the Person type, we could do something like this:
personList.stream().forEach(x->x.setName("New name"));
Hi there. If there are any suggestions for improving the channel - write.

One of them, did you have a desire to improve the post, or even write your own?

If so, how do you like the idea of making a bot in which you can write your post, or some additions to one of the existing ones.
#jvm
Metaspace?

Metaspace is a special partition of memory in the Java virtual machine. It is located in the Runtime Data Area and is not part of the heap.

It is used to manage memory for metadata class.

Metadata of a class is a describtion of class fields, methods stored in a special object. Every class has own (meta) Class object.

Metadata class are allocated when classes are loaded. Their lifetime is usually scoped to that of the loading classloader - when a loader gets collected, all class metadata it accumulated are released in bulk. The memory manager does not need to track individual allocations for the purpose of freeing them.

Notes:
- Metaspace by default auto increases its size
- Max size can be set using XX: MetaspaceSize
- Comparatively effective Garbage collection. Deallocate class data concurrently and not during GC pause.
- In versions before Java 8 instead of Metaspace was PermGen Space
The best but not ideal map of JVM

Obviously not the prettiest blue line😁
#news #java

Oracle doesn't want Java EE any more

Oracle wants someone else to lead enterprise Java, though it says it will stay involved. Apache and Eclipse are likely candidates to take over Java EE.

Oracle wants to end its leadership in the development of enterprise Java and is looking for an open source foundation to take on the role.

The company said today that the upcoming Java EE (Enterprise Edition) 8 presents an opportunity to rethink how the platform is developed. Although development is done via open source with community participation, the current Oracle-led process is not seen agile, flexible, or open enough. ”We believe that moving Java EE technologies to an open source foundation may be the right next step, to adopt more agile processes, implement more flexible licensing and change the governance process,” Oracle said in a statement.
Why in functional programming languages recursion is faster compare to cycle?

Hi folks. I haven't written anything in a long time but now I have interesting topic to share.

You probably know that in Java recursion is much slower compare to loops. And It makes sense, because in recursion each time is created some stack frame. Each stack frame require some memory allocation and so on. So when we use recursion all time time during invocation your size of stack frames increasing. Same stuff in C++/C and in C#.

You can check it by writing Fibonacci numbers i.e.

But recently I figure out that in Haskell recursion works faster. And in mostly functional programming languages. Bot of course id depends on algorithm. The main reason is - Compiler is better in optimizing pure functions. He can make optimization more eagerly and aggressive.

"The key concept here is purity: a pure function is a function with no side effects and no state. Functional programming languages generally embrace purity for many reasons, such as reasoning about code and avoiding non-obvious dependencies. Some languages, most notably Haskell, even go so far as to allow only pure code; any side effects a program may have (such as performing I/O) are moved to a non-pure runtime, keeping the language itself pure."
Hi, we often work with JVM tuning.

Correct resource allocation, best performance is very important to each program.

Here is useful command to see all JVM options for tuning:

java -XX:+UnlockDiagnosticVMOptions -XX:+PrintFlagsFinal -version
Why is better always to use custom initial capacity for ArrayList?

So, ArrayList have two main parameters.

First one is capacity which defined by default as 10. Capacity is used to create empty array thus help to optimize list by static creation

And size — is size of actual elements which list contains.

When size of list = capacity — list recreate himself as array with newCapacity.

newCapacity = newCapacity + (oldCapacity >> 1)

Which means each time when your list will be full java will create new array.

That's why for better performance is good to use expected initial capacity.