About the "class" property/field
When you do: MyClass.class.someMethod() What exactly is the "class" field? I cant find it in the API docs Is it an inherited static field? I thought reserved keywords were not alowed as entity names. ...
When you do: MyClass.class.someMethod() What exactly is the "class" field? I cant find it in the API docs Is it an inherited static field? I thought reserved keywords were not alowed as entity names. ...
We are in the process of refactoring some code. There is a feature that we have developed in one project that we would like to now use in other projects. We are extracting the foundation of this feature and making it a full-fledged project which can then be imported by its current project and others. This effort has been relatively st...
I've been developing Windows Forms/Windows services/webservices for most of my career using VB (before .NET), then strictly C# since it was released. Now, I've recently lost my job and starting to think I may not be able to get a job in my town - Las Vegas. I'd like to be able to apply for some of the Java jobs to increase my chance of...
I have some data formated like the following 2009.07.02 02:20:14 40.3727 28.2330 6.4 2.6 -.- -.- BANDIRMA-BALIKESIR 2009.07.02 01:38:34 38.3353 38.8157 3.5 2.7 -.- -.- KALE (MALATYA) 2009.07.02 00:10:28 38.8838 26.9328 3.0 3.0 -.- -.- CANDARLI KÖRFEZI (EGE DENIZI) 2009.07.01 23:3...
I want the Java compiler to give me the highest level of warnings possible. Currently I compile with -Xlint. Is there anyway for me to get more warnings? The warnings provided by Xlint seem paltry. I just compiled this code with -Xlint and got no warnings: double x = 22/7; double y = 22/7; if(x == y) { System.err.println("They are e...
Its great when you can return a null/empty object in most cases to avoid nulls, but what about Collection like objects? In Java, Map returns null if key in get(key) is not found in the map. The best way I can think of to avoid nulls in this situation is to return an Entry<T> object, which is either the EmptyEntry<T>, or contains the va...
I need to implement a server in which has only one selector(static); multiple threads try to register channel to the same static selector. I tried to implement the server, but the problem is that the static selector works for first time i.e. registers the channel; but on next call to register different channel the thread gets hanged. I...
I am trying to make an animated clock using Swing in Java. The picture I have posted is a basic idea of what I am looking for. In the end I hope to have the arrow be stationary and the numbers move to indicate the hour, plus I want to have a nested circle with 60 boxes doing the same. I'm not looking for code on how to do this just some ...
I'm using a class that extends BytecodeScanningDetector to check for some problematic fields in a class. After detecting whether the field is problematic, I add it to the bug report like below: Once I run findbugs, it identifies the bug, lists it in the left pane, but does not highlight the corresponding source line. Any hints/help o...
If i have an array say - int[] a = new int[10]; does the Java GC when doing its collection see that as 10 objects or a single object? Update: so according to the given answers, looking at it from a GC perspective isnt it more efficient that instead of List l; for(i =0;i<1000;i++) l.add(new MyObj(343,"asdfasfd")); we should d...
Hi! I have excel file with such contents: A1: SomeString A2: 2 All fields are set to String format. When I read file in java using poi it tells that B1 is numeric cell format. The problem is that the value in A1 can be 2 or 2.0 so I can't just use .toString(). Can anyone help please? ...
Hi guys, I've got a little game that a friend and I are writing in Java. It's kind of badly coded and we're working on refactoring it, but that's not really the issue right now. We both have 64 bit machines and I guess before we were both using 32 bit JDKs, but recently I had some problems and so I removed all JDKs and installed the lat...
I'm getting the error in the title occasionally from a process the parses lots of XML files. The files themselves seem OK, and running the process again on the same files that generated the error works just fine. The exception occurs on a call to XMLReader.parse(InputStream is) Could this be a bug in the parser (I use piccolo)? Or is ...
Can you please advice on the best way to check if a server is running using java? I mean I want to check a site for downtime. Is connecting to the server and getting the status (if 200 returned then it's up!) the right way? Won't this slow down the server in case connection is established and status checked every 60 seconds? I'm curren...
Is it possible to render google maps in swing or applet? I know i can also use NASA World Wind but it seems to much overkill for a simple app. ...
Is it possible in JSP to get the type of Object in List, just like we do in Java myDataBind.getResultsList().get(0).getClass(); or is it possible to achieve something like this: if ( myDataBind.getResultsList().get(0) instanceOf MyClass ) { doThis; } i don't prefer scriptlets, but if it is not possible to do without scriptlets th...
So in java, say you have a non-static method 'bar()' in an class 'Foo'. class Foo { private int m_answer; public Foo() { m_answer = -1; } public void bar(int newAnswer) { m_answer = newAnswer; } } Say then that you call this method like so: Foo myFoo = new Foo(); myFoo.bar(42); Now the...
Usecase maintain a list of the last n visited URLs (where n is a fix number). As new URLs are added to the list, older urls are removed automatically (in order to keep it at n elements) Requirement The data structure needs to be sorted by time (should be no problem if it accepts a Comparator). ...
just think that when I opened my file then when I want to write something in it ,one Exception will be thrown,and if I used file.close() in the try block ,So because of that Exception will not work, where should I close my file??? ...
I am interating through classes in a Jar file and wish to find those which are not abstract. I can solve this by instantiating the classes and trapping InstantiationException but that has a performance hit as some classes have heavy startup. I can't find anything obviously like isAbstract() in the Class.java docs. (many thanks for the ra...