Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Java



  String.length() vs String.getBytes().length in Java

In Java, String.length() is to return the number of characters in the string, while String.getBytes().length is to return the number of bytes to represent the string with the specified encoding. By default, the encoding will be the value of system property file.encoding, the encoding name can be set manually as well by calling System.setProperty("file.encoding", "XXX"). For example, UTF-8, Cp1252. In many cases, String.length() will return the same value as String.getBytes().length, but in some ...

   Java,UTF8,String,Encoding,Sample     2015-04-01 22:22:23

  A return to good code

Stop doing this:public boolean foo() { if (true) {   return true;   }  else {   return false;   }}It always amazes me when I dig into an open source project, and I see code written by supposed experts, and reviewed by seasoned professionals, and nobody slaps the wrists of the developer who shoves return statements right in the middle of a method.Tell me, how hard is it to do this:public boolean foo() {   boolean flag = true;  ...

   Java,Code,Method,Return,Condition     2011-03-23 01:24:47

  10 reasons why Dart is cooler than JavaScript

Dart is a new programming language from Google and after coding JavaScript for over one year now, I immediately felt in love with it. Coming from the Java world I had a good bunch of things I had to learn before I could use JavaScript. Some people say, you need to dig deep into JavaScript, otherwise you are not allowed to speak about the pros and cons of a language. I am not a JavaScript Ninja. But I strongly believe a programming language should be easy to learn, easy to understand and s...

   Dart,JavaScript,Comparison     2012-01-05 08:23:21

  Why accessing Java HashMap may cause infinite loop in concurrent environment

HashMap in Java is frequently used to handle key/value pairs. But it is not a good candidate to be used in concurrent environment where ConcurrentHashMap should be used instead. If used in concurrent environment, it may cause lots of unexpected behavior even including make the program getting into an infinite loop situation. To understand how this can happen, let's first discuss how HaspMap works internally. In this post we will use implementation of HashMap before Java 8 as example, Java 8 prov...

   JAVA,HASHMAP,INFINITE LOOP     2020-03-29 01:47:00

  TIOBE : What's the future of C#?

TIOBE released the programming language index for August 2012, the top 3 programming languages are still C, Java and Objective-C. Objective-C still performs well after it ranked 3rd place last month, it's still rising. Is there any possibilty Object-C will overtake Java in the near future? However, Microsoft's C# doesn't look so good. C# is generally recognized as the enterprise language with most modern and expressive features available today and C# has shown more downward trends in the past an...

   TIOBE,August,C#     2012-08-13 14:48:11

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

   OOP design,Principle,Java     2012-03-14 13:51:38

  Maybe we need //Comment comment

Do we need comment in our programs? Depends, if we can write a program which can clearly tell s the reader what the program does, then we had better to avoid unnecessary comments. However, if the program we develop is complex enough and it involves some uncommon logic which needs more explanation, then we have to add comment and make sure the comment we add can correctly tell the readers what we do. The worst scenarios is not you forget or you don't want to add comment, it's that you add comment...

   comment,programming     2014-07-23 04:38:04

  Deep Understanding of ReentrantLock: Unlocking the Mysteries of Java Concurrent Programming

ReentrantLock introduction ReentrantLock is a class in the Java concurrent package, java.util.concurrent.locks, and is an implementation of the Lock interface. As its name suggests, it is a reentrant mutual exclusion lock. A mutual exclusion lock is a synchronization tool used to protect shared resources, ensuring that only one thread can access the resource at a given time. Reentrant means that a thread can acquire the same lock multiple times without causing a deadlock. This lock provides some...

   JAVA,REENTRANTLOCK,CONCURRENCY,MULTITHREADING     2023-05-22 08:01:13

  Java Interview Questions

Currently there are many articles online which summarize the list of Java interview questions. Some cover lots of basic questions and some cover some specific questions in specific area such as multithreading. In this post, we will not cover the really basic questions, we will cover something different. For basic question, you can read Java Interview Questions。 Basic What is primitive data type? How many primitive data types in Java? What are they? -- A primitive type is prede...

   JAVA,SECURITY,INTERVIEW,CAREER,MULTITHREADING,QUESTION,JAVA INTERVIEW,JAVA CORE     2019-01-21 07:07:08

  Top 20 programming languages in April 2011

Next picture shows the Top 20 programming languages in April 2011 from TIOBE. From the picture, we can find the most popular programming languages are the different representatives of programming language styles. And some of them are popular because the platforms which use this programming language is very popular.For example C#, because of Microsoft, this language is used in .Net platform. Many users are using this programming language.Also, Java, C and C+ are the top 3 languages in he world. T...

   TIOBE,Ranking,Programming language. C,C+     2011-04-05 14:20:03