background preloader

Java Generics FAQs - Frequently Asked Questions

Java Generics FAQs - Frequently Asked Questions
All text and content found at URLs starting with (collectively, "the Java Generics FAQ") are the sole property of Angelika Langer. Copyright @ 2004-2016 by Angelika Langer . All rights reserved. Except as specifically granted below, you may not modify, copy, publish, sell, display, transmit (in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise), adapt, distribute, store in a retrieval system, create derivative works, or in any other way use or exploit the contents of the Java Generics FAQ, without the prior consent of the author. All rights, titles and interest, including copyrights and other applicable intellectual property rights, in any of the material belongs to the provider of the material. You do not acquire proprietary interest in such materials by accessing them on my web site. In particular, I do NOT grant permission to copy the Java Generics FAQ or any part of it to a public Web server. Commercial Use Disclaimers

http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html

Related:  JavaJava - General

Factory Chain: A Design Pattern for Factories with Generics by Hugo Troche - developer.*, Developer Dot Star Introduction The recent Java 5 (a.k.a. Java 1.5) generics implementation opens both new problems and new opportunities in the implementation of the "Gang of Four" (GoF) Factory patterns [Gamma, et al 1995]. On the one hand, we want a class factory to determine the type it will instantiate at run time. On the other hand, when we use generics correctly the compiler has to be able to determine the type of any call at compile time; casting with generics is considered unsafe.

The Java HotSpot Performance Engine Architecture Table of Contents Back to Top Chapter 1. Introduction and Overview The Java HotSpot™ virtual machine implementation (Java HotSpot™ VM) is Sun Microsystems, Inc.'s high-performance VM for the Java platform. Recent Java 8 News Java 8 developments are starting to dominate the news again. Recent posts cover extending Milestone 7 of JDK 8 to ensure its feature complete, the Date/Time API now available in Java 8, and updates to the Java Tutorials to cover some Java 8 features. Extending JDK 8 M7 An Introduction to Generics in Java > Generic Methods Like generic classes, methods and constructors can also have type parameters. These parameters are declared prior to the return type of the method and can be used as return types, argument types, and in the throws clause. For example, see Listing 4. Listing 4 Generic method—finds max T 1 public <T extends Comparable> T max(T t1, T t2) { 2 if (t1.compareTo(t2) > 0) 3 return t1; 4 else return t2; 5 } Here, the method "max(...)" has a single type parameter "T" declared as "<T extends Comparable>".

FriendPackages - APIDesign From APIDesign Common object oriented languages offer some kind of encapsulation, which often takes form of having public, protected and private access modifiers. Indeed, designers soon found that this is not enough and as such C++ has friend keyword and Java adds additional package private access type. The problem with the Java approach is that it generally dictates the files layout of your friends. Their sources need to be placed in the same directory.

Using Java as Native Linux Apps – Calling C, Daemonization, Packaging, CLI (Brian McCallister) We Recommend These Resources This is a summary of the excellent JavaZone 2012 talk Going Native (vimeo) by Brian McCallister. Content: Using native libraries in Java and packaging them with Java apps, daemonization, trully executable JARs, powerful CLI, creating manpages, packaging natively as deb/rpm. 1. Using Native Libs in Java Calling Native Libs Privacy and Security Fanatic: Busted! DOJ says you might be a felon if you clicked a link or opened email We may be doomed and you are probably a felon if you ever used a fake name online, used a bogus birthday to register on a site, or fibbed about your height or weight on an online dating profile, named a different town or city in a profile, or basically didn't tell the exact truth anywhere online. Never done that? No problem, then you're probably busted under the "obtains information" portion of the Computer Fraud and Abuse Act (CFAA). According to George Washington University Professor of Law Orin Kerr, "Any information of any kind is enough" to qualify you as a criminal under the Justice Department's broad interpretation of CFAA. Kerr said that includes, "Routine and entirely innocent conduct such as visiting a website, clicking on a hyperlink, or opening an e-mail."

An Introduction to Domain Driven Design Click here to view the complete list of archived articles This article was originally published in the Winter 2009 issue of Methods & Tools An Introduction to Domain Driven Design Java theory and practice: Hashing it out While the Java language does not provide direct support for associative arrays -- arrays that can take any object as an index -- the presence of the hashCode() method in the root Object class clearly anticipates the ubiquitous use of HashMap (and its predecessor, Hashtable). Under ideal conditions, hash-based containers offer both efficient insertion and efficient retrieval; supporting hashing directly in the object model facilitates the development and use of hash-based containers. Defining equality The Object class has two methods for making inferences about an object's identity: equals() and hashCode().

Which Java Thread Consumes my CPU? We Recommend These Resources What do you do when your Java application consumes 100% of the CPU? Turns out you can easily find the problematic thread(s) using built-in UNIX and JDK tools. No profilers or agents required.

Related: