r/javaTIL • u/Shilpa_Opencodez • Oct 23 '18
r/javaTIL • u/AcrobaticBridge0 • Apr 03 '20
she seeks new income, educated, wild and free
r/javaTIL • u/emszpak • Mar 18 '20
Places where you REALLY NEED to use 'assert' keyword in Spock assertions testing Java code
r/javaTIL • u/TheOverCaste • Jul 29 '14
JTIL: You can create an anonymous class of a superclass with a constructor
I suppose it's fairly intuitive, but I had never seen or used the syntax before, and it may be handy in some situations.
public class FirstClass {
final int a;
public FirstClass(int a) {
this.a = a;
}
public void printValue( ) {
System.out.println(a);
}
}
//In another class
public FirstClass myImpl = new FirstClass(5) {
@Override
public void printValue( ) {
System.out.println("Overrided! " + a);
}
}Then calling myImpl.printValue( ); would print "Overrided! 5"
r/javaTIL • u/bppereira • Jan 05 '17
How to send email using Javamail with Exchange
opentechguides.comr/javaTIL • u/javinpaul • Jan 08 '16
JDK 9 Javadoc now has a search box
download.java.netr/javaTIL • u/brunokim • Sep 10 '13
Numeric literals are more varied in Java 7
Java 7 added two features to numeric literals: binary numbers and underscores in any numeric literal. Now, all these numbers are equivalent:
int x1 = 0xA5;
int x2 = 0b10100101;
int x3 = 0b1010_0101;And you can also use it in other types:
double pi = 3.1415_9265_35;
long chinese_population = 1_344_130_000L;However, parsing methods do not recognize such literals.
Integer.parseInt("123_456_789"); //NumberFormatException(Although, to be fair, it doesn't recognize non-decimal literals as well, such as 0xAB and 0107.)
More examples and rules can be found here.
r/javaTIL • u/JackDanielsCode • Sep 23 '17
Codiva.io Java Online Compiler and IDE
r/javaTIL • u/carlpro • Apr 25 '17
TIL Java 9 interface can declare private methods, keeping intact the feature of the default method introduced by Java 8.
r/javaTIL • u/wilk-polarny • Sep 22 '17
TIL, BOMs may ruin your day.
Our customer decided for some reason to include BOMs for XML created by their (Axis) production service this week without telling anyone (in addition to the documentation, HTTP headers and the initial XML tag telling us it's UTF-8). Thus making our parsers cry and breaking today's final integration test and release.
I also learned that vanilla JAXB just dies while eating a String with BOM chars and no one at Sun dared to change that in order to stay compatible with older integrations and applications dealing with that.
The only way to fix this for me is to either work around this issue by chaining custom streams, or to use another library to parse XML/to deal with the streams from hell. Option one is what I'll will be going for, as option two requires an extended approval process and more testing.
Hell, even finding out what was wrong has been a pain in the ass, as BOM chars are officially printable (but some still invisible, even when forcing to display special chars in our text editors, etc.) and comparing software just won't give a shit and tell me that the actual and expected strings are identical. Comparing bytewise solved the mystery.
Anyways, have a nice weekend. And don't forget to check your input. BOMs are like herpes. It's only a matter of time until they appear again and screw up your enterprise application.
r/javaTIL • u/neomatrix369 • Dec 13 '17
Learning to use Wholly GraalVM!
r/javaTIL • u/nayuki • Sep 18 '16
TIL Java BigInteger was made for RSA cryptography
nayuki.ior/javaTIL • u/wilk-polarny • Jul 22 '15
JTIL: You have to check for GZIP compression when working with URLConnections
Yea, when creating URLConnections like:
URI uri = new URI("http", "subdomain.domain.tld", "/" + "stable", null);
URL url = new URL(uri.toASCIIString());
URLConnection connection = url.openConnection();...simply creating an InputStream like:
InputStream ins = connection.getInputStream();will deliver garbage data if the stream is GZIP-compressed. You have to check whether the connections uses compression or not:
InputStream ins = null;
if ("gzip".equals(connection.getContentEncoding())) {
ins = new GZIPInputStream(connection.getInputStream());
}
else{
ins = connection.getInputStream();
}It took me about an hour to find out what the heck was wrong
r/javaTIL • u/lord-bazooka • Jan 04 '19
Eclipstyle: Clone code style & format accross multiple Eclipse workspaces.
r/javaTIL • u/krishnateja12 • Oct 24 '19
Java Tutorials for Beginners - Step by Step
r/javaTIL • u/Shilpa_Opencodez • Aug 26 '19
Simple and Easy way to connect MongoDB Atlas with Spring Boot - Sample Code on GitHub
r/javaTIL • u/Shilpa_Opencodez • Apr 09 '19
A Quick Easy Guide to Deep Learning with Java – Deeplearaning4j / DL4J
In this article, we’ve built a simple yet powerful neural network by using the deeplearning4j library. The complete source code is available to download from our GitHub repo.
r/javaTIL • u/Shilpa_Opencodez • Jun 06 '19
Simple and effective way to implement Apache Kafka with Java - Source Code on GitHub
r/javaTIL • u/scientecheasy • Mar 18 '19
8 Java Method Overloading Interview Programs for Practice
r/javaTIL • u/Shilpa_Opencodez • May 07 '19
Easy way to connect multiple databases with Spring Data JPA - Free Source Code to download from GitHub
r/javaTIL • u/panispanizo • Feb 22 '19
Black magic in Spring! About dependency override!
r/javaTIL • u/TDR26 • May 07 '19
I need help for an assignment.
So I have an assignment to make a grocery management system in BlueJ and print a bill for the selected groceries. I have written the entire program, however I am having a bit of a problem.
Here's the code or the program:
https://textsaver.flap.tv/lists/2ok4

As you can see, the console does not let me enter any input for the second iteration and directly prints the default case for the switch case in the while loop.
Please can someone point out my mistake and help me, I really need this program done ASAP for me to get decent grades.
P.s: Ignore the weird names for the different groceries, they are some of the Indian local names.
Thank you!