java tutorial

What if I were 1% charged?

Gravity and Levity

In case you hadn’t heard, the universe is governed by four fundamental forces.  But when it comes to understanding nature at almost any level larger than a nucleus and smaller than a planet, only one of them really matters: the Coulomb interaction.

The Coulomb interaction — the pushing and pulling force between electric charges — is almost incomprehensibly strong.  One common way to express this strength is by considering the forces that exist between two electrons.  Two electrons in an otherwise empty space will feel pulled together by their mutual gravitational attraction and pushed apart by the Coulomb repulsion.  The Coulomb repulsion, however, is stronger than gravity by 4,000,000,000,000,000,000,000,000,000,000,000,000,000,000 times.  (For two protons, this ratio is a more pedestrian $latex 10^{36}$ times.)

When I was a TA, I enjoyed demonstrating this point in the following way.  Take a balloon, and rub it against the top of your head until…

View original post 1,083 more words

java tutorial

11 Best Practices for Low Latency Systems

One of the must read article for Java programmers, it’s the lesson you will learn after spending considerable time tuning and developing low latency systems in Java in 10 minutes.


stopwatchIts been 8 years since Google noticed that an extra 500ms of  latency dropped traffic by 20% and Amazon realized that 100ms of extra latency dropped sales by 1%. Ever since then developers have been racing to the bottom of the latency curve, culminating in front-end developers squeezing every last millisecond out of their JavaScript, CSS, and even HTML. What follows is a random walk through a variety of best practices to keep in mind when designing low latency systems. Most of these suggestions are taken to the logical extreme but of course tradeoffs can be made. (Thanks to an anonymous user for asking this question on Quora and getting me to put my thoughts down in writing).

Choose the right language

Scripting languages need not apply. Though they keep getting faster and faster, when you are looking to shave those last few milliseconds off your processing…

View original post 763 more words

java tutorial

Android Interview Questions for Java Programmers

Android is Google’s operating system for mobile devices and smartphones which has provided Java a much needed boost couple of years back. Now millions of Java developers are developing Android apps e.g. games, utilities and applications. Demand of Java developers who knows Android is quite large in market and several Java developers are also learning Android with the hope to get Job in this booming Industry. If you are going for Android Job interview, then don’t forget to practice these frequently asked Android questions for Java programmers.

See list of Android Interview Questions

java tutorial

Difference between Nested, Inner, Local and Anonymous class in Java

There are two types of nested class in Java, static and non-static, later is also known as Inner class. Main difference between them is that static class is not associated with Outer class instance and you can create its instance without having an Outer class instance, but Inner classes are associated with Outer class instance and cannot be created without them.

There are mainly two types of nested class in Java, static and non-static. Out of these two, static nested class are simply refereed as nested class while non-static nested class are known as Inner class in Java. Inner class is further divided into member class, local Inner class and Anonymous Inner class. Where first one is simply a non static member of the class, second one is declared inside local scope e.g. inside a method or block and third one is special type of class which is implemented at the time of initialization, since it doesn’t have name and it cant be reused its known as Anonymous class.

to read more, see full tutorial

java tutorial

Solving FizzBuzz Challenge in Java 8

FizzBuzz is one of the most popular programming exercise, which is used by Interviewer to separate Coders who can’t code. It’s also those kind of exercise you would like to do when you start learning new programming language e.g. Ruby, Python or C#.  So when many programmer asked me how to learn new features of Java 8 e.g. functional way of coding using lambdas, using streams, Optional and other feature, I suggest them to solve common coding problems using these feature. It is not only interesting but also very fruitful and my first exercise was to solve FizzBuzz challenge in Java.

Java 8 is in town for more then a year, but do you really know how to FizzBuzz in Java 8 using lambda expression and streams? If not then see this article : FizzBuzz Solution in Java 8.

java tutorial

Reading String from File in one line – Java 8

File IO was not easy in Java, you need to write tons of cod eto do small things e.g. reading String from File or writing text into file, but gone are the days when you need to write several lines of code to read file in Java. JDK 7’s new File API combined with Java 8 Stream API makes reading file a one liner job.
Read more How to Read File in One Line in JDK 7 or Java 8.

java tutorial

What is difference between Java and JavaScript programming language?

TL;DR, Java and JavaScript are as different as Car and Capet. Java and JavaScript are two totally unrelated programming language, all they have in common is the word “Java”. JavaScript was originally designed as scripting language to make your HTML live and aptly named as LiveScript initially. I am sure internet and programming world would have been less confused had NetScape has not renamed it to JavaScript, just to cash in popularity of Java.

BTW, Today is totally different, JavaScript is as popular as Java and dominant client side scripting world and now starting gaining market share on server side programming with node.js, where Java has ruled for so many years.

Read more  10 difference between Java and JavaScript for Programmers.