background preloader

Discovering java

Facebook Twitter

All about java.util.Date. This post is an attempt to reduce the number of times I need to explain things in Stack Overflow comments.

All about java.util.Date

You may well be reading it via a link from Stack Overflow – I intend to refer to this post frequently in comments. Note that this post is mostly not about text handling – see my post on common mistakes in date/time formatting and parsing for more details on that. There are few classes which cause so many similar questions on Stack Overflow as java.util.Date. There are four causes for this: Date and time work is fundamentally quite complicated and full of corner cases.

Quora. Winterbe/java8-tutorial. Understanding sun.misc.Unsafe - DZone Java. The biggest competitor to the Java virtual machine might be Microsoft's CLR that hosts languages such as C#.

Understanding sun.misc.Unsafe - DZone Java

The CLR allows to write unsafe code as an entry gate for low level programming, something that is hard to achieve on the JVM. If you need such advanced functionality in Java, you might be forced to use the JNI which requires you to know some C and will quickly lead to code that is tightly coupled to a specific platform. With sun.misc.Unsafe, there is however another alternative to low-level programming on the Java plarform using a Java API, even though this alternative is discouraged. Nevertheless, several applications rely on sun.misc.Unsafe such for example objenesis and therewith all libraries that build on the latter such for example kryo which is again used in for example Twitter's Storm.

Pattern (Java Platform SE 6) 10 Things You Didn't Know About Java. So, you’ve been working with Java since the very beginning?

10 Things You Didn't Know About Java

Remember the days when it was called “Oak”, when OO was still a hot topic, when C++ folks thought that Java had no chance, when Applets were still a thing? I bet that you didn’t know at least half of the following things. Let’s start this week with some great surprises about the inner workings of Java. 1. There is no such thing as a checked exception That’s right! Today, everyone agrees that checked exceptions were a mistake. Do you want proof that the JVM doesn’t know such a thing?

01.public class Test { 04. public static void main(String[] args) { 05. doThrow(new SQLException()); 08. static void doThrow(Exception e) { Parameter passing - Is Java "pass-by-reference"

TextView/webView

Get Involved. Android is an open-source software stack created for a wide array of devices with different form factors.

Get Involved

The primary purposes of Android are to create an open software platform available for carriers, OEMs, and developers to make their innovative ideas a reality and to introduce a successful, real-world product that improves the mobile experience for users. We also wanted to make sure there was no central point of failure, where one industry player could restrict or control the innovations of any other. The result is a full, production-quality consumer product with source code open for customization and porting. Android was originated by a group of companies known as the Open Handset Alliance, led by Google. Today, many companies -- both original members of the OHA and others -- have invested heavily in Android. The companies that have invested in Android have done so on its merits because we believe an open platform is necessary. On Memory Leaks in Java and in Android. Just because it’s a garbage collected language doesn’t mean you can’t leak memory or run out of it.

On Memory Leaks in Java and in Android.

Especially on Android where you get so little to begin with. Now of course sometimes the answer is that you just need more memory. If your program is a Java command line program to load the entire road map of the United States to do some network algorithms, you probably need more than the default JVM configurations give you.

Sometimes it’s not even a full-on leak, but a large chunk of memory isn’t being released in time as a consequence of some holder object that isn’t being released in time. Track memory allocations. Despite the impressive hardware of the first Android phones (T-Mobile G1 and ADP1) writing efficient mobile applications is not always straightforward.

Track memory allocations

Android applications rely on automatic memory management handled by Dalvik's garbage collector which can sometimes cause performance issues if you are not careful with memory allocations. In a performance sensitive code path, like the layout or drawing method of a view or the logic code of a game, any allocation comes at a price. After too many allocations, the garbage collector will kick in and stop your application to let it free some memory.

Most of the time, garbage collections happen fast enough for you not to notice. However, if a collection happens while you are scrolling through a list of items or while you are trying to defeat a foe in a game, you may suddenly see a drop in performance/responsiveness of the application. Once DDMS is running, simply select your application process and then click the Allocation Tracker tab. Trail: Learning the Java Language: Table of Contents (The Java™ Tutorials) Interface vs abstract class.