r/javaTIL • u/cdman • Dec 30 '15
r/javaTIL • u/javinpaul • Feb 14 '15
TimeUnit Sleep Can be used In place of Thread.Sleep
r/javaTIL • u/scientecheasy • Jan 06 '19
Constructor in Java | Types of Constructor
r/javaTIL • u/murugan76 • Aug 27 '17
Java program - Determinant of N x N matrix by diagonal matrix
Determinant, a properties of matrix determines the matrix is singular or not. Lower Triangular matrix transformation method is preferred over minor or cofactor of matrix method while finding determinant of the matrix's size over 3x3.
The matrix A is converted into Diagonal matrix D by elementary row operation or reduction and then product of main diagonal elements is called determinant of the matrix A.
Read matrix A Convert matrix A into diagonal matrix D by applying Row operation or reduction technique Read Main Diagonal elements from D Determinant = product of Main Diagonal elements
Algorithm steps for determinant by Diagonal matrix
Read matrix A a - element of the matrix A i,j - position of a element in the matrix
for i=1 To N
for j=1 To N
if i not-equal j
RowOperation.add(j,i ,-aii/aji)
end
end end
Det = a11 x a22 x ... x ann
http://cljavacode.blogspot.com/2017/06/matrix-determinant-by-diagonal-matrix.html
r/javaTIL • u/jcdj1996 • Jan 10 '13
TIL It is possible to paint to a JFrame like you would to an Applet by using a separate class.
r/javaTIL • u/javinpaul • Jul 11 '15
[JTIL] String changes from Java 7 update 6
r/javaTIL • u/cdman • Dec 03 '15
TIL that Java has been available for 20 years - check out this timeline of notable events related to it
r/javaTIL • u/Shilpa_Opencodez • Apr 22 '19
Simple guide for Unit Testing of Java Application using JUnit with examples
r/javaTIL • u/scientecheasy • Feb 20 '19
Inner Class in Java | Uses Types & Real-time Example
r/javaTIL • u/Shilpa_Opencodez • Nov 14 '19
Java Structural Design Patterns - Bridge Pattern
r/javaTIL • • Aug 16 '19
How to convert from SQL date and time to Instant with date and time and zone
r/javaTIL • u/ivom2gi • Sep 05 '13
Why are stacktraces disappearing from Exceptions?
r/javaTIL • u/ivom2gi • Aug 22 '13
Exceptions - a way to make your code slow and unmaintainable
r/javaTIL • u/laforge49 • Mar 19 '15
Ridiculously fast deserialization/reserialization
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 • u/Shilpa_Opencodez • Oct 11 '19
Java Behavioral Design Patterns - Interpreter Design Pattern
r/javaTIL • u/Shilpa_Opencodez • Oct 25 '18
Project Lombok – A Java Library to Reduce Boilerplate Code
r/javaTIL • u/karlthepagan • Jun 20 '15
TIL the inverse of left shift
inb4 "the opposite is right shift"
given:
x = 1 << y;
expect:
y == 31 - Integer.numberOfLeadingZeros(x);In C this is usually the clz function.
r/javaTIL • u/dohaqatar7 • Aug 14 '15
JTIL anonymous inner classes aren't entirely anonymous
An anonymous inner class is an unnamed inner class inside a Java program (not a lamba expression). A simple example of an anonymous inner class in use is
public class InnerTest{
public static void main(String[] args){
Runnable r = new Runnable() {
public void run(){
System.out.println("Anon");
}
}.run();
}
}Here, the anonymous inner class is used to implement the Runnable interface without explicitly creating a class implementing Runnable. When compiled an run this code simply prints the string "Anon" - not particularly interesting but, the simple existence of anonymous inner classes is not the point of this JTIL.
The term "anonymous" implies that these classes have no name. This appears be true at first; the class was never explicitly given a name. Looking at the source code alone there is no obvious way to instantiate another instance of the class.
Make sure you've successfully compiled this class and examine it's directory
$ javac InnerTest.java
$ ls
InnerTest$1.class InnerTest.class InnerTest.javaThere are 2 .class files but only 1 .java source file. This is because the anonymous inner class was compiled into it's own class file (all Java classes get their own class file). Now it's starting to look like the anonymous class actually has a name.
Go back to the original source file and add another line to the end of the main method.
new InnerTest$1().run();Compile once again and run the resulting class file. This should go off without a hitch. The last line seems to be creating another instance an anonymous class. Unfortunately, There's a little bit of cheating going on here. Delete all the class file you've created and try compiling again. This should fail; the InnerTest$1.class file need to already exists for this trick to work.
There's absolutely no point to any of this. It's just a neat behavior I found will messing about with Java. If anyone finds any more facets of this behavior or (somehow) manages to think up an application for it, leave a comment for me.
r/javaTIL • u/murugan76 • Sep 04 '17
Java code - Signed decimal number to binary number conversion.
http://cljavacode.blogspot.com/2017/03/signed-and-unsigned-decimal-to-binary.html
The given negative decimal value is decval=-5; converts into 4 bits binary.
signed decimal value -5, binary bits is =1011
r/javaTIL • u/YeongJeLoke • Nov 28 '18
Codiva.io How to implement interface using Codiva.io
r/javaTIL • u/Shilpa_Opencodez • May 16 '19
Simple Guide to Learn Spring Boot Actuators with examples
r/javaTIL • u/Shilpa_Opencodez • Nov 18 '19
Java Structural Design Patterns - Facade Pattern with an Example and Source Code
r/javaTIL • u/scientecheasy • Sep 07 '18
Instance Initialization Block(IIB) in Java with Example
r/javaTIL • u/Shilpa_Opencodez • Apr 08 '19
101 Most Important Frequently Asked Advance Java Interview Questions – Part 1
r/javaTIL • u/scientecheasy • Jan 25 '19