HTML

3 Ways to Convert String to Short in Java

In last a couple of examples, I have taught you how to convert String to Integer, Long, Double, Float, Boolean, and Byte in Java and today I will show you how to convert String to Short in Java, but before that let's revise what is short data type in Java. The short is an integral data type similar to the int but it only takes 2 bytes to store data as compared to 4 bytes required by an int variable. Since it takes only 2 bytes or 16 bits to store data, the range of short is also shorter than int. It ranges from -32,768 to 32767 (inclusive) or -2^15 to 2^15 -1. You might be wondering why upper bound is 255 and lower bound is -256 but that's because we have included zero in between.

2 Ways to Add Binary Numbers in Java - Coding

In the last article, I have shown you how to subtract binary numbers in Java and today, you will learn the opposite i.e. how to add binary numbers in Java. You can do binary addition in Java either by writing your own logic or by taking advantage of the Java API, which allows you to convert a binary String into a binary number. Though, if you want you can also use the logic I have shared in my earlier post about how to check binary numbers to verify input before converting it to a binary number. In this article, we'll take a look at both methods of adding two binary numbers in Java.

How to Rotate an Array to Left and Right by Given Number in Java?

Hello guys, welcome to this post with another array based coding problem. In the last article, we've learned about finding missing numbers in the array with duplicates and today we'll solve the problem of rotating an array by left or right by given number. For example, suppose an integer array {1, 2, 3} is given and it was asked to rate this array to the left by 3 then the result array will look like {2, 3, 1} because it was rotated twice on left. Similarly if asked to rotate the same array twice by right then we'll get {1, 2, 3}, the same array is back. This is an interesting problem and it's quite easy to solve but I have many programmers struggles with this one as well. So, a little bit of practice and learning will not hurt.

Difference between @SpringBootApplication vs @EnableAutoConfiguration annotations in Spring Boot

Even though both @SpringBootApplication and @EnableAutoConfiguration can be used to enable the auto-configuration feature of Spring Boot there is a subtle difference between them. The @SpringBootApplication does much more than what @EnableAutoConfiguration do. It's actually a combination of three annotations: @Configuration which is used in Java-based configuration on Spring framework, @ComponentScan to enable component scanning of components you write e.g. @Controller classes, and @EnableAutoConfgiuration itself, which is used to enable auto-configuration in Spring Boot application. Spring Boot designers realize that these three annotations are frequently used together so they bundled them into @SpringBootApplicaiton. Now, instead of three annotations you just need to specify one annotation on your Main class.

How to Implement a Power Function in Java - Coding Problems

Even though the Java library has a power function, Math.pow() to calculate the power of a given number in Java, it's a common programming exercise for Java programmer to implement a power function. If you have used the Math class then you know that the java.lang.Math.pow(double a, double b) returns the value of the first number raised to the power of the second number and you need to do the same. In other words, you need to write a Java function to calculate the power of integer numbers for simplicity. The original method accepts a double value but you are allowed to use just integer but beware that power function may overflow.

Top 20 System Design Interview Questions for Java Programmers

System design questions are an important part of programming job interviews and if you want to do well, you must prepare this topic. In the past, when I shared my list of programming interview questions, I have shared a couple of System design questions but my readers kept asking me for more questions, as it is a hard topic to master and more and more practice is needed. I had my own list of questions which I have collected from various interviews with friends and colleagues but I needed more questions for this article and my own preparation then I stumbled upon Grokking System Design Interview course. It's an excellent resource because it not only gives you a lot of System design question but also provide all the knowledge and tools you need to solve those questions.

Java - String charAt Example - How to get first and last characters

The charAt(int index) method of java.lang.String class can be used to retrieve a character from given index. The method returns a character, you can see its return type is char. The index starts from zero and ranges to length() - 1 where length() return the length of String. It's similar to an array where the first element is stored at zeroth index and the last element is stored at length -1 index because String is nothing but backed by a character array. If the value of the index is invalid i.e. it's lower than zero or negative or higher than length - 1 then this method throws an IndexOutOfBoundsException. In this article, I'll show you a couple of example of how to use the charAt() method to retrieve a character from String in Java.

Top 75 Programming Interview Questions Answers to Crack Any Coding Job Interview

Hello guys, if you are preparing for your next Programming Job interview and looking for some frequently asked Coding or Programming questions to practice then you have come to the right place. In this article, I am going to share some of the most commonly asked Coding questions from Programming Job interviews. In order to do well on the Coding interview you need practice, you just can't go there and expect to solve the coding problems in limited time. Sometimes, the interviewer also asks little bit easier coding questions on telephonic interview e.g. revering array in place or reversing a string in place.

Top 5 Amazon Web Services or AWS Courses to Learn Online - FREE and Best of Lot

Hello guys, if you want to learn Amazon Web Services, popularly known as AWS and looking for some awesome resources e.g. books, courses, and tutorials then you have come to the right place. In this article, I am going to share some of the best Amazon Web Services or AWS courses which will help you to learn this revolutionary and valuable technology free of cost. Unlike other paid courses, these are genuine free AWS courses which are made free by their authors and instructors for the promotional and educational purpose. You just need to enroll with them and then you can learn AWS at any time, at any place and on your own schedule. But, if you are completely new to AWS domain or Cloud let me give you a brief overview of Amazon Web Services and its benefits over traditional infrastructure setup.

How to java.lang.NoClassDefFoundError: org/springframework/beans/factory/SmartInitializingSingleton in Spring Boot

Problem:
I was trying to run a HelloWorld program using Spring Boot when I got this error:

Exception in thread "main" java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration#propertySourcesPlaceholderConfigurer due to internal class not found. This can happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:52)
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:92)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:174)
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:136)

Top 5 Free TypeScript Courses to Learn Online - Best of Lot

If you are interested in learning TypeScript or Angular, one of the popular JavaScript framework for developing front-end, which uses TypeScript and looking for some resources e.g. books, tutorials and courses then you have come to the right place. In this article, I am going to share some of the best, free TypeScript online courses you can use to learn this powerful programming language. For those who don't know TypeScript, it's a new dynamically typed programming language from Microsoft which augments JavaScript's programming syntax by adding some new features which help in object-oriented application development, particularly introduction of Types.

Top 5 Free Big Data Courses to learn Hadoop, Spark Online - Best of Lot

If you want to learn Big Data technologies in 2018 e.g. Hadoop, Apache Spark, and Apache Kafka and you are looking for some free resources e.g. books, courses, and tutorials then you have come to the right place. In this article, I am going to share some of the best free online courses to learn Hadoop and Spark from Udemy and Pluarlsight at your own pace. I personally like to start with FREE resources before I have enough knowledge to choose the right book or enroll in a little expensive course. It's also my passion to surf web to find great free resources and share with you guys.