JAVA


  The several flavors of random in Java

Random number generation is one of most basic features in any programming language. The basic utilization is always the same: generate a random number between 0 and 1. With such a simple resource at hand we sometimes overlook some interesting features.What do we learn from the books?The most obvious and maybe intuitive way to generate random numbers in Java is simply calling:java.lang.Math.random()Random generation is in the Math utility class with abs, pow, floor, sqrt and other mathematical functions we see in all other languages. Most people will learn about this class...

4,072 0       JAVA TYPE MATH THREAD RANDOM


  10 Object Oriented Design principles Java programmer should know

Object Oriented Design Principles are core of OOPS programming but I have seen most of Java programmer chasing design patterns like Singleton pattern , Decorator pattern or Observer pattern but not putting enough attention on Object oriented analysis and design or following these design principles. I have regularly seen Java programmers and developers of various experience level who either doesn't heard about these OOPS and SOLID design principle or simply doesn't know what benefits a particular design principle offers or how to use these design principle in coding.Bottom line is always strive...

5,493 0       JAVA PRINCIPLE OOP DESIGN


  Java vs F#

Dr Cliff Click of Azul Systems, specialists in manycore JVM systems, recently published a blog post about the performance of Java compared primarily to C and C++ but also discussing C# and .NET. Three of Cliff's comments are of particular interest:Under the heading "Places where C/C++ beats Java for obvious reasons":"Value Types, such as a 'Complex' type require a full object in Java." - Dr Cliff ClickWhat Cliff forgot to mention is that .NET also provides value types and a far more compelling example than complex numbers is the humble hash table.Consider the task of filling a hash table with ...

4,087 0       JAVA PERFORMANCE JVM F#


  Java Sequential IO Performance

Many applications record a series of events to file-based storage for later use.  This can be anything from logging and auditing, through to keeping a transaction redo log in an event sourced design or its close relative CQRS.  Java has a number of means by which a file can be sequentially written to, or read back again.  This article explores some of these mechanisms to understand their performance characteristics.  For the scope of this article I will be using pre-allocated files because I want to focus on performance.  Constantly extending a file imposes a significa...

3,107 0       JAVA IO SEQUENTIAL BLOCKING


  10 Points about Java heap memory

When I started java programming I didn't know what is java heap or what is heap space in Java, I was even not aware of where does object in Java gets created, it’s when I started doing professional programming I came across error java.lang.outofmemoryerror then I realized What is Heap in Java or Java Heap Space. Its happens with most of programmer because learning language is easy but learning basics is difficult since there is no formal process which can teach you every basics of programming its experience and work which reveals the secret of programming. For Java developer knowledge o...

5,606 0       JAVA TIPS HEAP MEMORY


  Tricks with Direct Memory Access in Java

Java was initially designed as a safe managed environment. Nevertheless, Java HotSpot VM contains a “backdoor” that provides a number of low-level operations to manipulate memory and threads directly. This backdoor – sun.misc.Unsafe â€“ is widely used by JDK itself in packages like java.nio or java.util.concurrent. It is hard to imagine a Java developer that uses this backdoor in any regular development because this API is extremely dangerous, not portable, and volatile. Nevertheless, Unsafe provides an easy way to look into HotSpot JV...

4,157 0       JAVA TRICKS JVM DIRECTLY MEMORY ACCESS


  Regex vs IndexOf in Java.

OverviewThe author of these articles Are C# .Net Regular Expressions Fast Enough for You? and .Net Regex: Can Regular Expression Parsing be Faster than XmlDocument or Linq to Xml? recently pointed out to me that he had found that Regular expressions were at least as fast or faster than the alternatives in C#. However it has been my experience that regular expressions in Java were slower. It is hard for me to say why this might be different in Java and C# or even if these are fair comparisons but here is what I found in Java.Searching XML for the start of a fieldThis test searches for the exp...

6,193 0       JAVA INDEXOF REGULAR EXPRESSION EFFICIENCY


  Finding selected checkbox items in a JSF dataTable

This is one of those problems that I couldn’t find a complete example for when I needed it, so hopefully this will save somebody else the extra time it took me to piece it together.We frequently need to have data tables in our UI, and allow the user to select a subset of those items for action. In JavaServer Faces, this means having a DataTable, each row having its own checkbox. But when the action is triggered, how to we find which items the user has selected.The first step is to add a boolean property to your objects that can represent the selection. If you have a lot objects in your ...

14,768 1       EXAMPLE JAVASERVER FACES JSF DATATABLE CHECKBOX