Postingan

Menampilkan postingan dengan label coding

How to Remove all Unused imports in a Java file - Eclipse Shortcut

Gambar
How to remove all unused imports in Eclipse Eclipse IDE gives warning "The import XXX is never used" whenever it detects unused import in a Java source file and shows a yellow underline. Though unused import in Java file does not create any harm , it's unnecessary increase length and size of Java source file and if you have too many unused imports in your Java source file, those yellow underline and Eclipse warning affect readability and working. In my last post on Eclipse, we have seen some Java debugging tips on Eclipse and in this post, we will see Eclipse shortcut to remove all unused imports in Eclipse. There are many options to tackle this problem e.g. you can collapse import section of code in Eclipse or you can altogether remove all unused imports from Java file, and we'll see them in this short tutorial. If you are completely new to Eclipse IDE, then I suggest you to first go through a comprehensive course likeThe Eclipse Guided Tour - Part 1 and 2 from Pl...

How to declare and initialize a List (ArrayList and LinkedList) with values in Java - Arrays.asList() Example

Gambar
Hello guys, today, I am going to share with you a useful tip to initialize a List like ArrayList or LinkedList with values, which will help you a lot while writing unit tests and prototypes. Initializing a list while declaring is very convenient for quick use, but unfortunately, Java doesn't provide any programming constructs like collection literals of Scala, but there is a trick which you can use to declare and initialize a List at the same time. This trick is also known as initializing List with values . I have used this trick a lot while declaring list for unit testing and writing demo programs to understand an API etc and today I'll you'll also learn that. If you have been using Java programming language for quite some time then you must be familiar with the syntax of an array in Java and how to initialize an array in the same line while declaring it as shown below: String[] oldValues = new String[] {"list" , "set" , "map"} or even shorter...

Top 6 Books to Learn and Master Programming and Coding - Must Read, Best of Lot

Gambar
Coding is an integral part of Programming, and we all somehow learned to code by following examples here and there. Yes, I am talking about both self-taught programmer and Computer Science Graduates. You can learn Coding easily if you are dedicated, but what is more difficult is to write good code. You can easily find programmers in Java, C++, Ruby or Python, but finding programmers, who are also a good coder is very difficult. Some universities have a good curriculum and practical classes to teach coding better than others, but most of these great coders are self-taught Programmers, who learned by reading books, joining online courses and doing things on their own. The point is self-learning is VERY important in the field of Programming and Coding, you just cannot rely on your college and university to make you an expert programmer, you have to make that extra effort to distinguish yourself from the group and what could be better than by learning coding and wisdom of programming from ...

Clean Code by Uncle Bob - Book Review - Must read for Software Engineers

Gambar
Even though the Clean Code book was released many years ago and there are lots of good reviews already available, I couldn't resist to write my own experience of this great book. I came across this book many years ago, but since then, I have read it multiple times, and I have recommended it to my readers, students, and fellow developers. It is one of those books which make you feel that why didn't you come across it earlier, I felt the same when I first learned about this book. The Clean Code is all about writing good quality code, and how do you judge the quality of code? Well, you won't appreciate good until you have seen bad code and that's what this book does. It first presents a code, which is ugly, hard to read, hard to understand, hard to maintain and then Uncle Bob goes step by step to refactor that code and converting them into the masterpiece you would be proud of writing. You will get a taste of how to convert a bad code to good code when you first read his ...

Top 20 String Algorithm Questions from Coding Interviews

Gambar
In this article, we are going to see top 20 String based coding interview question and their solution to help programmers better prepare for interviews. The string is one of the most important data structure and available in almost every programming language like Java, C, C++, Python, Perl, and Ruby. Though there implement differ the essence remains same like String is NULL terminated character array in C butString is an object in Java, again backed by character array. The string is also available on weekly typed languages like Python and Perl.  This is why you will always find some String based coding question on programming interview. Even in your college days, you would have solved lots of coding problems based upon String like reversing String in place, checking if String is a palindrome, checking if two strings are an anagram of each other, calculating permutations of String etc. The coding questions from programming interviews are also not very different from that, but yes it...

Top 5 Websites to Learn Java Online for FREE - Best of lot

Gambar
Begin the author of a Java blog, I often receive questions like how to improve my coding skills?,  or how do I learn to code in Java?, or I am having difficulty solving programming problems, please help, etc. This is mostly from programmers who have just started programming or a graduate with a programming degree or even some programmers with a year or two in Job. Like many other things in the world, to improve coding, you need to code, code, and code - and to develop programming, you need to write a program, and that's where many of these programmers fail. In 90% cases, they simply don't write enough programs to develop programming logic and code sense and, if without too much experience at data structures and algorithms, if they attempt problems given on sites like LeetCode, HackerEarth, TopCoder or Project Euler, they fail miserably. To be frank, it's not easy to solve problems from those sites, until you have really done programming for a year or two, or even more. An e...

Top 5 Books for Programming/Coding Interviews - Best of lot

Gambar
If you are preparing for Programming Job interviews and looking for some of the best books for programming questions, then you have come to the right place. In this article, I am going to share a couple of good books to prepare coding, software design, and data structure algorithm questions, which are essential for any coding interviews. Though a programming interview also explores other areas of software development, e.g., the programming language, you would be mainly used in your project, like, C++ or Java. The database and SQL based questions, the operating systems, and UNIX related questions, some of the software design and object-oriented design pattern questions, and much more, but coding based questions form the core of programming interviews. This article solely contains books for coding interviews, but if you are interested in finding good books on other topics, likeconcurrent programming or Java and other topics, then just look at those links and some more I have shared a...

3 Examples of Parsing HTML File in Java using Jsoup

Gambar
HTML is the core of the web, all the pages you see on the internet are HTML, whether they are dynamically generated by JavaScript, JSP, PHP, ASP or any other web technology. Your browser actually parse HTML and render it for you. But what would you do,  if you need to parse an HTML document and find some elements,  tags, attributes or check if a particular element exists or not from Java program. If you have been in Java programming for some years, I am sure you have done some XML parsing work using parsers like DOM and SAX, but there is also good chance that you have not done any HTML parsing work. Ironically, there are few instances when you need to parse HTML documents from core Java application, which doesn't include Servlet and other Java web technologies. To make the matter worse, there is no HTTP or HTML library in core JDK as well; or at least I am not aware of that. That's why when it comes to parsing an HTML file , many Java programmers had to look at Google to find ...

Common Multi-threading Mistakes in Java - Calling run() instead of start()

Gambar
Writing multi-threaded and concurrent programs is not easy, not even in Java.  Even senior developers, including myself, make mistakes while writing concurrent Java applications. This is also one of the trickiest area of Java programming language, where misconceptions outnumbers concepts. Considering amount of misconception an average Java programmer has about multi-threading and concurrency, I thought to start a new series about common multi-threading mistakes done by Java programmers; what is better way to learn from common real word mistakes. Learning from mistakes has another name Experience , but if you only learn from your mistakes then there is only limited things you can learn, but if you learn from other peoples mistake, you can learn much more in short span of time. Have you ever thought, Why writing multi-threaded code is difficult? IMHO, primary reason for this is that it multi-threading makes it hard for a code to speak for itself. Programmer read code sequentially to...

How to write Production quality code?

Gambar
We often hear the term "production quality code", some times in an interview where the interviewee asked to write production-quality code for a particular function, sometimes discussion between developers and programmers and sometimes during code review. I know most of you familiar with the term but for those who wonder what is production quality code in simple terms its code which can bear the test of time in a production environment. We all develop code in development, then test in QA and finally, it gets released in production. But there is a lot of difference between test and prod and if you have not coded taking prod environment in mind most likely code will fail in prod or result in exceptions. So what makes the production environment different than development environment? Here are a few things which I noted: 1) Production is all about the load which will expose concurrency issues , load issues, memory, and CPU issues. 2) You will get a lot many scenarios in producti...