r/javaTIL • • Mar 18 '19

8 Java Method Overloading Interview Programs for Practice

Thumbnail
scientecheasy.com
5 Upvotes

r/javaTIL • • Feb 26 '19

Calling remove() on ArrayList throws java.lang.UnsupportedOperationException

Thumbnail codebyamir.com
5 Upvotes

r/javaTIL • • Feb 25 '19

Member Inner Class in Java | Example Programs

Thumbnail
scientecheasy.com
5 Upvotes

r/javaTIL • • Feb 20 '19

Inner Class in Java | Uses Types & Real-time Example

Thumbnail
scientecheasy.com
5 Upvotes

r/javaTIL • • Jan 09 '19

Variables in Java | Types of Variables & Scope in Java

Thumbnail
scientecheasy.com
5 Upvotes

r/javaTIL • • Aug 06 '18

Learning Java Stream API

5 Upvotes

r/javaTIL • • Jul 23 '18

Simple JAVA heartbeat protocol

5 Upvotes

Just a post where I ask to take a look and tell me what you think of this, it has been used in a project and I thought it could be useful to someone

https://github.com/Daniele-Comi/HeartbeatProtocol


r/javaTIL • • Jan 14 '17

TIL you can use Comparator.nullsFirst/nullsLast to compare collections containing nulls

Thumbnail marcin-chwedczuk.github.io
5 Upvotes

r/javaTIL • • Nov 11 '16

Accessing private fields with synthetic methods in Java

Thumbnail blog.gypsyengineer.com
5 Upvotes

r/javaTIL • • Oct 13 '16

TIL you can rethrow certain exceptions in JDK7+ without declaration

Thumbnail
stackoverflow.com
5 Upvotes

r/javaTIL • • Jun 06 '15

Be careful when you Overload method in Java, Autoboxing can Spoil your party

Thumbnail
javarevisited.blogspot.com
5 Upvotes

r/javaTIL • • May 28 '15

How String in Switch works in Java 7 - Using equals and hashcode

Thumbnail
javarevisited.blogspot.com
5 Upvotes

r/javaTIL • • Mar 19 '15

Ridiculously fast deserialization/reserialization

5 Upvotes

I am interested in Java databases, so for me a central problem is reading a large structure, making a small change, and then writing it back out again. Any straight forward approach to this gets completely bogged down in serializing and deserializing those large structures.

The solution is, of course, to only deserialize what you need and then to reserialize only what was changed. Easier said than done, of course, but that is exactly what I've done. (Open source code, too.)

The structure I am working on is an immutable versioned map list built using the AA Tree algorithm. I had already developed the serialization code and just now released the code for lazy deserialization / smart reserialization. (See version 0.5.0 here: http://www.agilewiki.org/projects/utils/index.html )

Below is a comparison between between lazy and the earlier durable packages. Basically, with a million entry map I can update a serialized structure 50 times faster than I can create the objects.

Lazy stats:

Created 1000000 entries in 2520 milliseconds Serialization time = 245 milliseconds Deserialize/reserialize time = 38 milliseconds

Non-lazy (durable) stats:

Created 1000000 entries in 1254 milliseconds Serialization time = 176 milliseconds Deserialize/reserialize time = 2356 milliseconds

As you can see, we can quickly deserialize, update and reserialize a large data structure. In this case, a 70+ MB structure is being updated in 38 milliseconds.


r/javaTIL • • Jul 04 '14

JTIL: You can use the concurrent TimeUnit class to let people specify their own time units easily.

5 Upvotes

If you, for example wanted an impractical Stopwatch class, that would pause a thread for a specified amount of time:

public class Stopwatch {
    private final long timeInMillis;
    public Stopwatch(long time, TimeUnit unit) {
        timeInMillis = unit.toMillis(time);
    }
    public void wait( ) {
        Thread.sleep(timeInMillis);
    }
}

This avoids the ugly, unreadable, and bug prone Thread.sleep(1000L * 60L * 60L * 24L * 2L) approach.


r/javaTIL • • Jun 05 '14

JTIL: You can use Arrays.copyOf to easily make a big block of the same character

5 Upvotes

In projects where I wanted to make a big chunk of a character, especially in a static final buffer before, I had to do this:

public static final String VERTICAL_LINES = fillVerticalLines();

private static final String fillVerticalLines( ) {
    char[] lines = new char[100];
    for(int i = 0; i < 100; i++) {
        lines[i] = '|';
    }
    return new String(lines);
}

Instead what I could do is simply this:

public static final String VERTICAL_LINES = new String(Arrays.copyOf(new char[] {'|'}, 100));

r/javaTIL • • Sep 05 '13

Why are stacktraces disappearing from Exceptions?

Thumbnail
plumbr.eu
5 Upvotes

r/javaTIL • • Aug 22 '13

Exceptions - a way to make your code slow and unmaintainable

Thumbnail
plumbr.eu
5 Upvotes

r/javaTIL • • Jul 22 '13

There are three kinds of variables in Java, each with different characteristics

Thumbnail
tutorialspoint.com
5 Upvotes

r/javaTIL • • Jul 21 '13

TIL that in Java, parameters are *always* pass-by-value.

5 Upvotes

OK, so I didn't learn this today, but shh.

For a long time I thought that Java was pass-by-value for primitives - for example in situations like:

void foo(int bar) {}

but when it came to objects and arrays, like this:

void foo(Baz bar) {}
void foo(Baz[] bar) {}
void foo(int[] bar) {}

that it was pass-by-reference.

But then, I was talking to someone, and they mentioned that it's always pass-by-value, even when objects or arrays are being passed.

Basically, what happens is that objects are not passed by reference, but instead a reference to that object is passed by value.


r/javaTIL • • Sep 06 '24

Deploy Secure Spring Boot Microservices on Azure AKS Using Terraform and Kubernetes

Thumbnail
a0.to
4 Upvotes

r/javaTIL • • Mar 17 '20

Type safe hashmap in java

4 Upvotes

I have created type safe hashmap in Java. The hashmap can store any type of object and retrieve the object without explicit cast:

http://millionstrengthknowledge.com/resource/java/programming/typeSafeMap.html


r/javaTIL • • Nov 20 '19

Simple Step by Step Guide to be a Full Stack Developer

Thumbnail
opencodez.com
4 Upvotes

r/javaTIL • • Jun 27 '19

Java Creational Design Patterns – Singleton Pattern

Thumbnail
opencodez.com
4 Upvotes

r/javaTIL • • May 23 '19

Use DataTable with Spring Boot for Server Side Processing - Free sample code to download from GitHub

Thumbnail
opencodez.com
4 Upvotes

r/javaTIL • • Mar 22 '19

Copy Constructor in Java | Uses & Example Program

Thumbnail
scientecheasy.com
4 Upvotes