Today's Question:  What weekend projects have you created?

#### Permutation implementation in Java

Permutation is a very basic and important mathematic concept we learned in school. It has very practical applications in real world. For example, in football. In simple, permutation describes all possible ways of doing something. For example, there are six permutations of the set {1,2,3}, namely: (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), and (3,2,1). In general, for n items, there are n! number of permutations to arrange these items. How can we implement this algorithm in programming programm...

Permutation,Implementation,Java,Sample     2015-03-26 02:18:14

#### Is Java the platform of the future?

I've mentioned before, but I think we are living in a period of time where a bigger explosion of programming languages is occurring than at any time in the past four decades. Having lived through a number of the classic languages such as BASIC, Simula, Pascal, Lisp, Prolog, C, C++ and Java, I can understand why people are fascinated with developing new ones: whether it's compiled versus interpreted, procedural versus functional, languages optimised for web development or embedded devices,...

Java,Platform,Future     2012-04-03 12:59:52

#### Hexadecimal and long in Java

Today I encountered a hexadecimal operation problem when I was implementing a bit reverse function for integer type. Basically in the implementation, there is an operation which is to do the bit operation & between one long integer and a hexadecimal number 0x00000000FFFFFFFFF. I was expecting that the high 32 bits of the long integer will be zeroed. But unfortunately I didn't get the expected result. The basic implementation is: long num=0x00F0_0000; num = (num>>16) | (num<<16); ...

Hexadecimal,long,Java,bitwise operation     2014-06-18 23:44:32

#### A boolean value interview question

Someone asked a question on StackOverflow, he was asked an interview question. The question is : Given 3 boolean variables a, b, c, return true if at least 2 out of the 3 are true. He gave the solution as follows :boolean atLeastTwo(boolean a, boolean b, boolean c) {    if ((a && b) || (b && c) || (a && c)) {        return true;    } else {        ret...

bool,return,expression,conditional     2012-04-30 08:49:32

#### Solution to getKeyCode() returns 0 in Java

The getKeyChar method always returns a valid Unicode character or CHAR_UNDEFINED. Character input is reported by KEY_TYPED events: KEY_PRESSED and KEY_RELEASED events are not necessarily associated with character input. Therefore, the result of the getKeyChar method is guaranteed to be meaningful only for KEY_TYPED events.For key pressed and key released events, the getKeyCode method returns the event's keyCode. For key typed events, the getKeyCode method always returns VK_UNDEFINED....

Java,KeyCode,0,KeyListener     2011-06-06 10:38:11

#### Who’s the winner: Python vs. Java, C/C++?

If there is one debate that never dies in the language community then it is this: Who’s the winner: Python Vs Java, C/C++. Obviously each has its own pros and cons, but in which language do the pros outnumber the cons or which language has better cons than others! For some it just comes down to familiarity, they like what they like!   The Numbers  But as far as the rest of the language world goes, the debate is still out there. By last count, Java, C and C++ were still winning. A...

JAVA,INDIA,DEVELOPERS     2017-09-11 00:38:25

#### What will the value of Integer.valueOf(127) == Integer.valueOf(127) be in Java?

Do you really understand how Java does the integer comparison? OK, ignore the statements in the post title. What we are interested in is another set of comparison statements. Let's first see below code snippet. public class IntegerComparison { public static void main(String[] args) { Integer a = 127, b = 127; Integer c = 128, d = 128; System.out.println(a == b); System.out.println(c == d); } } What do you think the output will be? Are they both displaying true? You will find out t...

JAVA,==,EQUALSTO     2018-01-13 22:18:15

#### 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...

#### Java AbstractMethodError explained and demonstrated

According to Oracle Java API documentation, AbstractMethodError is a kind of runtime error where the application is having some incompatible changes which leads to a missing implementation of an abstract method. Below is the official description. Thrown when an application tries to call an abstract method. Normally, this error is caught by the compiler; this error can only occur at run time if the definition of some class has incompatibly changed since the currently executing method was last co...

JAVA,ABSTRACTMETHODERROR     2016-07-22 22:03:20

#### Using Java keytool programmatically

Java provides a command line tool to access and operate different keystore which store keys and certificates. This tool is named keytool and is located at \bin.  On command line, you can issue below command to generate a keystore named mytest.jks which contains a private key and certificate chain. keytool -genkeypair -alias mykey -keyalg RSA -sigalg SHA256withRSA -dname CN=Java -storetype JKS -keypass password -keystore mytest.jks -storepass password Sometimes, in testing purpose, w...

JAVA,KEYTOOL     2016-01-09 06:28:07