Java is Pass-by-Value, Dammit! - Scott Stanchfield. Introduction I finally decided to write up a little something about Java's parameter passing.
Java 7: Project Coin in code examples. We Recommend These Resources This blog introduces - by code examples - some new Java 7 features summarized under the term Project Coin.
The goal of Project Coin is to add a set of small language changes to JDK 7. These changes do simplify the Java language syntax. Less typing, cleaner code, happy developer ;-) Let's look into that. Prerequisites Install Java 7 SDK on your machine Install Eclipse Indigo 3.7.1 You need to look out for the correct bundles for your operating system. Thought Spearmints: @SuppressWarnings and its applicability to various program elements. Eamonn McManus's Blog: Getting rid of unchecked warnings for casts. Posted by emcmanus on March 30, 2007 at 3:27 AM PDT If you've ever made a serious effort to get rid of "unchecked" warnings from the Java compiler (the ones it gives you with -Xlint:unchecked) then you'll probably have found some cases where you know a cast is correct but you can't convince the compiler of it.
Is there anything better than adding @SuppressWarnings("unchecked") around the whole method? The problem with the @SuppressWarnings solution is that it's much too broad. It suppresses warnings for the whole method, even though it's just one little cast that you want to allow. What if there's another place in the method where the compiler would have given a warning, telling you about a real problem? Fortunately, there's a good solution. 10 examples of Enum in Java - What is Enum in Java Enum in Java is a keyword, a feature which is used to represent fixed number of well known values in Java, For example Number of days in Week, Number of planets in Solar system etc.
Enumeration (Enum) in Java was introduced in JDK 1.5 and it is one of my favorite features of J2SE 5 among Autoboxing and unboxing , Generics, varargs and static import. One of the common use of Enum which emerged in recent years is Using Enum to write Singleton in Java, which is by far easiest way to implement Singleton and handles several issues related to thread-safety and Serialization automatically.
By the way, Java Enum as type is more suitable to represent well known fixed set of things and state, for example representing state of Order as NEW, PARTIAL FILL, FILL or CLOSED. Enumeration(Enum) was not originally available in Java though it was available in other language like C and C++ but eventually Java realized and introduced Enum on JDK 5 (Tiger) by keyword Enum. Java SE APIs & Documentation. Get Ready for Java 7 with the Free JDK 7 Reference Card. Oracle submitted the release content for both Java SE 7 and 8 to the JCP at the end of last year.
The JDK 7 and 8 JSRs represented Oracle's "Plan B" approach for separating JDK 7 into two separate releases. In the months since, JDK 7 has progressed to the Developer Preview milestone and the final version isn't too far off. To provide developers with an at-a-glance reference guide of all the essential JDK 7 elements, Developer.com has published the JDK 7 Reference Card. Java Basics: Table of Contents [First Draft - June 2005] Trail: Essential Classes: Table of Contents (The Java™ Tutorials) Trail: JDBC(TM) Database Access: Table of Contents (The Java™ Tutorials) Java Programming Notes.
Top Ten New Things You Can Do with NIO. New I/O? Why do we need a new I/O? What's wrong with the old I/O? There's nothing wrong with the classes in the java.io package; they work just dandy -- for what they do. But it turns out there are quite a lot of things the traditional Java I/O model can't handle. Things like non-blocking modes, file locks, readiness selection, scatter/gather, and so on. NIO brings a host of powerful new capabilities to the Java platform. In this article I'm not going to explain buffers, channels, selectors, and the other denizens of the NIO depths.
So, without further ado, in the time-honored tradition of O'Reilly authors flogging their own books by cooking up lame top ten lists: Top Ten New Things You Can Do with NIO That You Couldn't Do Before (TTNTYCDW..., oh never mind). 10: File Locking File locking is one of those things most programmers don't need very often. With NIO, file locks are built right into the FileChannel class. Figure 1: Reader processes holding shared locks. Annotations. Many APIs require a fair amount of boilerplate code.
For example, in order to write a JAX-RPC web service, you must provide a paired interface and implementation. This boilerplate could be generated automatically by a tool if the program were “decorated” with annotations indicating which methods were remotely accessible. Other APIs require “side files” to be maintained in parallel with programs. For example JavaBeans requires a BeanInfo class to be maintained in parallel with a bean, and Enterprise JavaBeans (EJB) requires a deployment descriptor. It would be more convenient and less error-prone if the information in these side files were maintained as annotations in the program itself. The Java platform has always had various ad hoc annotation mechanisms.
Annotations do not directly affect program semantics, but they do affect the way programs are treated by tools and libraries, which can in turn affect the semantics of the running program. Annotations complement javadoc tags.