In Java, when you do
int b;
b = b + 1.0;
You get a possible loss of precision error. But why is it that if you do
int b;
b += 1.0;
There isn't any error?
While studying the Collection API, we find that some methods (add, remove,...) may throw a java.lang.UnsupportedOperationException if the current implementation of the Collection does not support those functionalities.
Is there,actually, in the JDK, a concrete Collection that does not support those methods ?
Thanks a lot for your answers.
i mainly focus on the web, i think i will never create desktop applications.
so i think it's better for me to focus on typical web languages like php.
i know an advantage java has over php is multi threading though.
will php ever support this feature in the future?
thanks
Is it safe to do connection.createStatement().executeQuery(String query);, or should each java.sql.Statement object be created and closed by "hand" on every use, even if the connection is closed in a finally block?
If multiple queries are executed in one method by one connection it would use much less code if instantiating and closing each statement wasn't strictly necessary.
I'm trying to create a REST based web service with data encapsulated using JSON. My problem is when I pass the string version of JSON in the URI it turns to something like this: %7B%22coal%22:100,%22ele%22:1500.1%7D.
I'm wondering if there are any functions Java for converting between the escaped and unescaped versions so I can parse the string.
Hello All,
I have made a program which is fetching data from server to and game to server. I want to keep these record in my file. But my problem is this is not in good format that i can read easily. I am reading all data as "Byte" (from java). Can anybody explain header or data info of packet. so I can read it in human manner Huh
thanks.
In my Java application I use a DateFormat instance to parse date inputs.
DateFormat fmt;
fmt = DateFormat.getDateInstance(DateFormat.DEFAULT) // dd.MM.yyyy for de_DE
The problem is that the user insists to enter dates in the form 31.12.11.
Unfortunately this is parsed to 31.12.11. (0011-12-31 in ISO format) Instead I want the parsed date to become 31.12.2011 (2011-12-31 in ISO format).
Can I modify the date format to somehow parse inputs that way?
i have used html in my java class and in one case i have used username.Username is a variable which gets values dynamically. in one case its value is 'rg@bg' but here instead of d name i m getting d url which it is directed to in my jsp. how do i ensure tht d value of username comes on d display page as it is.
i have tried "@"+username. didnt work
I'm a little bit confused about the difference between the two. An example of the Calendar API is supposedly located here: http://samples.google-api-java-client.googlecode.com/hg/calendar-android-sample/instructions.html, but the author himself suggests using the Calendar Provider API, details about which are here: http://developer.android.com/guide/topics/providers/calendar-provider.html.
Can someone explain to me the difference between the two, and which would be better for me to use for a simple calendar app?
Is anyone attempting to implement C# for the JVM? As a Java developer, I've been eyeing C# with envy, but am unwilling to give up the portability and maturity of the JVM, not to mention the diverse range of tools for it.
I know there are some important differences between the JVM and CLR but is there anything that is a showstopper?
I am using Groovy in a Java Swing application as part of my plan to force-feed myself dynamic languages until I like them (which is happening, partly).
My stack traces are filled with Groovy stuff like
org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor
is there a way to get Eclipse to remove all of that codehaus stuff (filter stack traces, basically)?
Edit: I can do this from the command-line with grep (well, not yet) so it's not so bad, but inside of Eclipse would be great too.
Now that i have learned the theory of OOPS in good number of books , and practised a little.
Still i am not comfortable when i look into OOPS being applied in some of the Open Source projs.
Can someone suggest any problem / solution kind of book , or any resources , that covers OOPS end - end. (C# , Java preferably)
the java doc describe that the constructor Date(long date) constructs a Date object using the given milliseconds time value since January 1, 1970, 00:00:00 GMT
actulely when i did new Date(0), the date is Jan 01 01:00:00 CET 1970
I don't know why it begin with 01h
This is a quesiton taken from a java exam,
How many objects are eligible for gabage collection at #1 ?
public class Main {
Integer x = 32768;
public static void main(String[] args)
{
Main m = new Main();
m = null;
// #1
}
}
I thought it just collect Integer x, does GC even collect the Main object m?
Hi!
I need execute some code before Windows shutdown process each time. So, I want block Windows shutdown process for some time. How can i do it from Java or C++ Builder ?
Thanks.
JFileChooser looks nothing like the native widget. I seem to remember reading some hack to get it look like the native widget but searching for it know i can't seem to find it again i came across posts that suggest using java.awt.FileChooser but that class does not seem to be in the distribution. How can i make JFileChooser make look like the native widget?
If I want to properly exit a documentum java job (if params are invalid for example), should I use a system.exit() or is there another way to do it.
As far as I know system.exit closes the virtual machine, does it have an effect on other jobs running?
I'm working my way through the NotePad tutorial, and that's all fine - I'm not a Java programmer but it's close enough to C# (or vice versa) to make it easy to pick up. I'm surprised that there aren't any RAD tools for Android apart from Mobiforms. Is there anyone out there with experience of Mobiforms ?
I am pulling a long timestamp from a database, but want to present it as a Date using Tags only, no embedded java in the JSP. I've created my own tag to do this because I was unable to get the parseDate and formatDate tags to work, but that's not to say they don't work.
Any advice?
Thanks.
Based on the post it is mentioned (By Brett Porter) that a POM can be read. What i need is to read not only a single pom. I need to read the whole tree of pom's in a multimodule build. Starting with the root pom and it should read automatically the child pom's if it's possible? I need to do this in separate Java Code not in relationship with Maven itself.
What is the recommended way of setting GET query parameters on a Restlet Request object?
I think I can see how to get them out of the request using getQueryAsForm(), but how do they get set in the first place?
At the moment, I am adding them manually to the URL using a StringBuilder and java.net.URLEncoder, but it seems like there should be a better way.
I have the following class
public class MyClass {
private int myAttr;
public void setAttr(int a) {
myAttr = a;
Thread.dumpStack();
}
}
That way I can detect any attempt to modify myAttr. Well, almost any. It does not work when someone modifies myAttr using Field.set() method. How can I trap Java reflection usage?
Given the adjacency matrix of a graph, i need to obtain the cromatic number (minimum number of colours within you can paint every node of a graph). preferably it should be a java algoryhtm, and i don't care about performance. thanks.
according to http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/html/clopts.html it should be possible to enable -XX:+HeapDumpOnOutOfMemoryError using JConsole in runtime. How?
I assume its somewhere under MBeans tab and the com.sun.management - HotSpotDiagnostic - Operations - setVMOptions ?