a peek into my MIND

April 2, 2014


Filed under: Java7Spec — Bharat Kondeti @ 12:07 am


A literal is a representation of a value of primitive type, string type or a literal type. A primitive literal can be a Integer literal / Float literal / Boolean literal / Character literal

- Integer literal can be decimal, hexadecimal, octal and binary
- Integer literal is of type long if it is suffixed with an ASCII letter L or l
- Underscores can be used as separators between integers
- Hexadecimal numerical starts with 0x or 0X followed by ASCII hexadecimal digits (0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,A,B,C,D,E,F)
- Octa numerical starts with 0 followed by ASCII digits 0 through 7
- Binary numerical starts with 0b or 0B followed by ASCII digits 0 or 1

// Decimal with underscore
 int decimal = 10_000_000;

// Hexa decimal
 int hexadecimal = 0X989_680;

// Octa decimal
 int octadecimal = 046113200;

// Binary
 int binary = 0B100110001001011010000000;

- Float literal can be decimal and hexadecimal
- Float literal is of type float if it is suffixed with an ASCII letter F or f
- By default, a Float literal is of type double and optionally it can be suffixed with an ASCII letter D or d

- Boolean literal can be true or false

- Character literal is represented as a character or a escape sequence enclosed in a ASCII single quotes
- Character literal can only represent UTF-16 code’s whose values are in between ‘\u0000′ to ‘\uffff’

- A String literal is a reference to an instance of String class
- A string literal always refers to the same instance of the String class
- String literals defined with in the same class / defined with in different classes of the same package / defined with in different classes of different packages all reference to the same String object instance

public class Sample {
    public static void main(String[] args) {
        String ss1 = "samplestring";
        String ss2 = "samplestring";

        System.out.println( ss1==ss2); //true
        System.out.println( ss1=="samplestring"); //true
        System.out.println( Sample2.ss=="samplestring"); //true
class Sample2 {
    public static String ss = "samplestring";

- String literals computed by constant expressions are computed at compile time and thus refer to same String instance

String ss = "samplestring";
System.out.println(ss=="sample" + "string"); //true

- String literals computed at runtime by concatenation are newly created and thus reference to different String instance

String ss = "samplestring";
String sample = "sample";
String str = "string";

System.out.println(ss == sample + "string"); //false
System.out.println(ss == sample + str); //false

- intern() method on the computed string will refer to the same String object reference to a literal, if that literal instance is already created

String ss = "samplestring";
String sample = "sample";
String str = "string";

System.out.println(ss == (sample + "string").intern()); //true
System.out.println(ss == (sample + str).intern()); //true

- A null type has a value of null reference that is represented by Null literal

March 15, 2014

Chrome shortcuts

Filed under: General — Bharat Kondeti @ 3:55 am

Here is the complete list of chrome browser shortcuts


Shortcuts that I frequently use for mac.

Cmd  + N to open new window, Cmd  + T to open new tab

Cmd  + F to open find bar, Cmd  + G to find next

Cmd  + W to close current tab, Cmd  + Shift + W to close window

Cmd  + L  to highlight the URL. This works on all browsers

Cmd  + Option + Left Arrow / Right Arrow to switch between tabs

Cmd  + , to open settings page. This works every where to open preferences

Cmd  + Option + I to open developer tools, Cmd  + Option + U to Open source code

Cmd  + Shift + Delete to open clear browser data dialog. This shortcut works on all browsers except for safari

Cmd  plus  to enlarge a page, Cmd  minus to shrink a page  and Cmd  zero to reset the page

Cmd  + colon to open spelling and grammar dialog , This shortcut works in all applications where you can write text and is very useful if you are bad at spellings like me

March 11, 2014

Component framework – Shield UI

Filed under: Tools — Bharat Kondeti @ 9:20 pm

Stumbled up on a feature rich component framework: Shield UI. Loved their charting components that you can drill down to show more information and their demos. They also have components for displaying barcodes and QR codes. All of the components are built using HTML5 and javaScript. They also have wrappers for chart, barcodes and QR codes in ASP.NET, .NET MVC and Apache Wicket. Definitely a nice framework for a data visualization website.

March 3, 2014

1. Keywords

Filed under: Java7Spec — Bharat Kondeti @ 6:01 am

Every language has some reserved words that cannot be used as identifiers called Keywords. Java has 57 such keywords. To get complete list go here – Java Keywords.

Few interesting things:

- const and goto are reserved keywords even though they are not used by the language.

- theory around volatile is bit complex. First we need to know that threads can cache data in processor cache memory for performance reasons rather than reading from / writing to main memory every time. In a single-core / multi-core processor, if multiple threads are working on the same variable with each thread using a different cache, they might not see the changes by other threads and will result in race conditions. To avoid this, if a variable is declared as volatile then threads will NOT cache that variable and is always read from / updated to the main memory.

There is one more concept called crossing the memory barrier. This means that when a memory barrier is crossed, JVM syncs all cached copies of variables to main memory and invalidates any cache that is marked as dirty in main memory. This is important because when a volatile variable is accessed, all the other variables that are cached are synced to main memory first. From Java 5 onwards, accessing a volatile variable will result in crossing a memory barrier.

Fixing the Java Memory Model – Part 1

Fixing the Java Memory Model – Part 2

- there is a keyword called strictfp as one of the reserved words. For performance reasons JVM can offload floating point calculations to the platform its running on. Since different platforms use different precisions for floating points, we would get different results when calculating floating points on these platforms. When this keyword is applied to a class, all the calculations inside the class will use strict floating point math by java runtime, resulting in same value on all the platforms. This keyword can be applied to a class, interface or a non abstract method.


0. Java 7 Specification And A Goal

Filed under: Java7Spec — Bharat Kondeti @ 6:01 am

Since it is never too late to have goals, I decided to have one, which is to read Java 7 Specification and blog about things that I did not know or thought were interesting. Also my hope is writing about these would help me to remember and get better understanding of some concepts.

Plan is to finish reading the specification in next 6 months… Hope I succeed….

February 17, 2014

Offloading user management to third party service

Filed under: screams — Bharat Kondeti @ 11:04 pm

While registering for a free online training on Play Framework from TypeSafe, noticed that they were using a third party service called Stormpath for their user management.

This is very interesting because user management is a tedious process and top of it having different roles, adds to the complexity. I had a first hand experience on user management when building a Grails application that required user registration and having different roles for users. At that time I used Acegi Security plugin that worked very well, but still managing user data, email validations, role management was a tedious process.

Using a third party service and their API totally makes sense when you are not worried about user data and you need a quick time to market

February 21, 2013

Web based browser testing

Filed under: screams — Bharat Kondeti @ 10:25 pm

Many websites offer cross browser testing by taking snapshots of a web page on various browsers and comparing them to find rendering issues. It works sort of, but when fixing a rendering issue its convenient to have access to a real browser.

On may mac, I have to setup multiple virtual machines to test IE browsers for compatibility issues, which sucks as a developer when you are running your web-server, IDE and a virtual machine.

Browser stack offers an interesting service where you can use different browsers from a browser. Its like actually testing on a browser with access to all the developer tools for a browser inside a browser. Wondering what would happen if I keep on opening browser stack sites inside a browser stack browser .



December 20, 2012

Some tools used at Tumbler

Filed under: General — Bharat Kondeti @ 11:21 pm

Nice presentation on Tumbler Architecture – Scaling Tumbler

Following are some tools mentioned in the presentation

Apache, PHP, Ruby, MySQL, Git

Scala + Finagle - Finagle is a network stack for the JVM that you can use to build asynchronous Remote Procedure Call (RPC) clients and servers in Java, Scala, or any JVM-hosted language. Finagle provides a rich set of protocol-independent tools.

Redis – Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

HBase – Apache HBase™ is the Hadoop database, a distributed, scalable, big data store.

Hadoop – The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models. It is designed to scale up from single servers to thousands of machines, each offering local computation and storage. Rather than rely on hardware to deliver high-avaiability, the library itself is designed to detect and handle failures at the application layer, so delivering a highly-availabile service on top of a cluster of computers, each of which may be prone to failures.

collectd – collectd is a daemon which collects system performance statistics periodically and provides mechanisms to store the values in a variety of ways, for example in RRD files.

OpenTSDB – OpenTSDB is a distributed, scalable Time Series Database (TSDB) written on top of HBase. OpenTSDB was written to address a common need: store, index and serve metrics collected from computer systems (network gear, operating systems, applications) at a large scale, and make this data easily accessible and graph-able.

Gearman – Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work. It allows you to do work in parallel, to load balance processing, and to call functions between languages. It can be used in a variety of applications, from high-availability web sites to the transport of database replication events. In other words, it is the nervous system for how distributed processing communicates.

Kafka – Apache Kafka is a distributed publish-subscribe messaging system.

HA-Proxy – The Reliable, High Performance TCP/HTTP Load Balancer.

Varnish – Varnish is a web application accelerator.

nginx – nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server.

Scribe – Scribe is a server for aggregating streaming log data. It is designed to scale to a very large number of nodes and be robust to network and node failures.

September 12, 2012

Online editor for HTML, CSS and JavaScript snippets

Filed under: Tools — Bharat Kondeti @ 6:57 pm

Nice tool for writing and distributing code snippets in HTML, CSS and JavsScript. You can save code snippets, share them or even embed them in your sites. For more documentation


September 11, 2012

Maven download source code for dependencies

Filed under: Java — Bharat Kondeti @ 10:00 pm

If you are using eclipse, then you can set maven preferences to download source and java doc

If you don’t want eclipse to automatically download source files then you can use maven to do that

mvn dependency:sources
mvn dependency:resolve -Dclassifier=javadoc

This will only work if there are sources and java doc’s available.

Older Posts »

The Shocking Blue Green Theme Blog at WordPress.com.


Get every new post delivered to your Inbox.