Skip to content
Advertisement

Is it possible to create an URL pointing to an in-memory object?

I’m trying to extend my library for integrating Swing and JPA by making JPA config as automatic (and portable) as can be done, and it means programmatically adding <class> elements. (I know it can be done via Hibernate’s AnnotationConfiguration or EclipseLInk’s ServerSession, but – portability). I’d also like to avoid using Spring just for this single purpose. I can create

What are fail-safe & fail-fast Iterators in Java

There are two types of iterators in Java: fail-safe and fail-fast. What does this mean, and is the difference between them? Answer What is the difference between them … “Fail-safe” (in engineering) means that something fails in a way that causes no or minimal damage. Strictly speaking, there is no such thing in Java as a fail-safe iterator. If an

Printing pyramid in Java on the console

How can I print a pyramid in Java like this My current code looks like this: If I try this removing declared i & j then it shows an array out of bounds exception However ‘i’ & ‘j’ are creating the problem. What should my code look like. Answer initially val is equal to 1 . Inside the first for

Java: why Thread.sleep() and yield() are static?

Why sleep() and yield() methods are defined as static methods in java.lang.Thread class? Answer The code would only execute when someXThread was executing, in which case telling someYThread to yield would be pointless. So since the only thread worth calling yield on is the current thread, they make the method static so you won’t waste time trying to call yield

Can’t remove jar from Web App Library

How can I remove the jars in my Web App Library? I manually added a couple jars to the web app library. My program is now pitching a fit so I clearly need to remove them. However, when I go to the Build Path, the “Remove” is greyed out. Answer A project’s Web App Library is composed automatically by Eclipse

How to know if now time is between two hours?

I have a now time: And I have some hour constants, for example, 23 and 8 (it’s 11pm or 23:00, 8am or 08:00). How I can know is now time between it’s two hour constants? It need to run some code of program or not to run if now time is between in two hours, for example, do not run

Get last week date range for a date in Java

Suppose I have a Date 20 June 2013 How can I get the Date range for the last week, ie in this case 9 June to 15 June. Also if the date was 2nd June 2013 the range should be 26 may to 1 june Answer this is Java Calendar based solution output it’s localized, in my Locale week starts

Advertisement