« first day (2167 days earlier)      last day (2773 days later) » 

1:47 AM
Integer i = new Integer(5);
Integer b = new Integer(5);
System.out.println(i.equals(b));
i did this and got an NPE. I thought that .equals worked fine when evaluating if 2 objects had the same state.
 
 
1 hour later…
3:02 AM
LOL wtf java. now the above code no longer produces an NPE. It works. wtf.
omfg now doing i.equals(null); works too! no more NPE
wtf is java
 
 
2 hours later…
fge
4:56 AM
@JohnnyCoder it will always work; the NPE was very probably somewhere else
 
@fge do you know much about GUI ? and Javaswing
 
fge
@ross.c no, I suck at GUIs
 
haha damn I'm trying to add to columns into one and i dont know how to do it -.-
*two columns
 
 
2 hours later…
user4196492
7:10 AM
I'm getting a Mac soon and I was wondering if it would be better coding Java on a Mac than on Windows. Is there a difference or benefit?
 
7:29 AM
@pebble225 Not particularly, unless you enjoy using the Terminal
If you're going with Eclipse or Intellij or whatever, the OS should have no real impact
I'm a CLI guy, so I use Linux
 
Hi
 
@fge hey
 
Is there any way to list ciphers supported by particular api or server ?
 
wow i have to write that linux script to get cipher .
 
7:42 AM
haha you bet
read other answers also :)
 
ok thanks
 
np :)
 
8:02 AM
morning
 
Hi, Why we have finally block in java if we can also close the resource without using it
 
is there a way in javadoc to cover several lines of variables under one docentry f.ex:
/**
* passed by {@link ITumInterface}
*/
private File [] exportfiles;
private DBTripReader tripReader;
private GeneralAnalyzer ga;
protected DefaultMutableTreeNode root = new DefaultMutableTreeNode(new AnalyzerCollection("ROOT"));
private String[] simulations;
private ArrayList<AnalyzerBase> baseAnalyzerList;
the above doc entry only covers exportfiles and I want to group all those variables under that entry
The class BufferedReader, in Java SE 7 and later, implements the interface java.lang.AutoCloseable. Because the BufferedReader instance is declared in a try-with-resource statement, it will be closed regardless of whether the try statement completes normally or abruptly (as a result of the method BufferedReader.readLine throwing an IOException).

Prior to Java SE 7, you can use a finally block to ensure that a resource is closed regardless of whether the try statement completes normally or abruptly.
in other words: prior to java7 u had to use the finally block to manually close the ressource
since java7 lots of "ressource" classes implement AutoCloseable that does it automatically for you
i hope that was what you were looking for :)
 
8:35 AM
morn
 
morning
 
8:50 AM
morning
 
9:06 AM
anyone on ?
 
no
 
9:19 AM
Thanks @motaa for sharing the information. But my question is
FileWriter fw = null;
try {
fw = new FileWriter(file);
if(!(fw == null))
{
fw.write("test");
fw.write("\data");
}
} catch (IOException e) {
e.printStackTrace();
}
fw.close();
we can also close the resource without finally block then why we need finally block ?
 
fge
@RaviKukreja that is not how you use a try-with-resources statement at all
Well, in fact you don't use try-with-resources at all
 
what if your code looks like
 
fge
Also, don't use FileWriter, this is 2016; use the new file API
 
FileWriter fw = null;
        try {
            fw = new FileWriter(file);
            fw.write("test");
            fw.write("\data");
            return true;
        } catch (IOException e) {
            e.printStackTrace();
        }
        fw.close();
        return false;
in that case fw still open
 
fge
try (final Writer writer = Files.newBufferedWriter(thePath);) { /* write into file, then: */ return true; } catch (IOException e) { return false; }
 
9:34 AM
no need closing the writer ?
@fge
 
fge
The try-with-resources statement does it for you
Just after the try block
(sorry for the quality)
 
@fge he wasn't asking about try-with-resources but why Java has a finally statement
 
fge
OK, but then, try-with-resources is pretty important
 
@RaviKukreja what would happen if inside your try block there was another exception for some reason, let's say a runtime exception? Then your resource wouldn't be closed
 
fge
As to why finally, well, this is to execute some code even if an uncaught exception is thrown
 
9:40 AM
@fge true, try-with-resources is important for someone who knows about basic Java resource handling and try-catch
 
@fge ok
 
@fge : I appreciate and agreed your answer but my question was for finally block used in java 1.7.
Thanks @Rahul for sharing the details and clear my doubt
 
10:13 AM
If I have a Java class, and 2 synchronised methods a() and b(), and both are synchronised on 'this', can one thread execute a() and a different thread execute b() at the same time?
does the synchronised keyword only related to a single synchronised method / block, or does it relate to ALL synchronised methods/blocks in a class
 
anyone know what im doing wrong
I can't seem to access the last column of my csv file I'm able to access everything else when i access the last column i get index out of bounds
so if i add this line i get that error content[i][4] = elements.get(i)[4];
 
 
2 hours later…
12:26 PM
@TheCoder that depends
if both Threads are working on the same instance, they have to wait, if they work on different instances, they can execute at the same time
broadly speaking, synchronized waits until Thread.holdsLock(obj)returns true.
with obj beeing the lock object defined in the statement
 
1:03 PM
Morning, Java!
 
ssc
How to mock a function that takes an object and one attribute of object is always random? [Mockito]
 
ssc
1:19 PM
Mockito.any is the answer
 
1:41 PM
@Nicktar
@Nicktar so if an object has 10 synchronised methods (on same object) and thread 1 enters synchronised method 1, then no other thread can enter the other 9 until thread releases it's lock?
it's a sort of greedy way of doing it?
 
 
2 hours later…
4:10 PM
@TheCoder that's why you can define different lock objects. It doesn't have to be this
define private final Object lock01 = new Object() to private final Object lock10 = new Object() in your class and use these.
but if you have to lock 2 methods in a way that only one of them can be executed at the same time, you might want to use lockX twice....
 
 
1 hour later…
5:13 PM
if you wanna post code, use hastebin or something similar to make it readable
 
 
1 hour later…
ssc
6:17 PM
How can I let spring-data application manage crypt(password,gen_salt('bf') in postgresql for passwords?
 
 
2 hours later…
8:43 PM
http://www.commitstrip.com/en/2016/09/28/meanwhile-on-mars-10/
CommitStrip
Meanwhile on Mars – #10
CommitStrip
1475094656
 
fge
8:59 PM
countryside-tesla.blogspot.fr <-- blog of my vehicle... In French (sorry)
2
 
9:25 PM
ah cmon french :D
@fge what kind of car is that?
oh got it a tesla :D
interestingly i understand every word you write there :ED
interestingly aswell I thought right of the bat that u are french hehe
hopefully you don't try that autopilot ;P
don't = won't
haha okk i should have read your blog till the end before I posted :D
 
9:51 PM
hello, from what I understand you should store datetimes in java 8 with either Instants or ZonedDateTimes. I have currently setup a spring boot app with an entity storing it as Instant. How could I write a JPA repository query that searches for this entity by day? (and not the entire timestamp)
 
fge
@motaa I did try it, and it works beautifully
 
for those cases u tried it :D
the thing is that there are like an infinite possibilities in traffic
that the autopilot has to consider
but I will keep reading ur blog :)
 
fge
Of course there are; and I am not stupid enough to rely on it all the time
 
been thinking about buying a car aswell and a tesla was the fiurst thing that popped in my mind
I know that dude :D didnt want to offend you :)
aight off to a round of lol
 
10:29 PM
I am looking for a sentence generator. Anyone?
 
11:01 PM
sorry @ChristianBongiorno 10hours of work and now a few beers... hard for me to concentrate on your problem right now :/ Will look at it in the morning
 

« first day (2167 days earlier)      last day (2773 days later) »