Want to start the year off right? Here is a range of topics you can tackle to make yourself a better Java dev from performance tuning to Spring Security 5.0.
First of all, I wish you a very happy new year, guys. It's that time of year when we start afresh, make plans, set goals, and make resolutions for the new year.
Being a Java developer and the author of a Java blog, I frequently receive requests from Java programmers from all over the world asking how they can improve themselves.
In the past, I have shared my 10 tips to become a better programmer, and every tip in that article still holds true, but given that it's a new year, I have decided to jot down new resolutions for Java programmers to improve themselves, enhance their knowledge of Java programming, and increase their value for future career growth.
So without wasting any more time, let's see my nine ideas for Java programmers in the new year, 2016. You can take inspiration from these ideas to create your own goals and resolutions.
Learn Java Performance Tuning
In the last a couple of years, I have taken more than 50 interviews for senior Java developers, and one skill that I clearly see lacking is knowledge and understanding about JVM internals, GC behavior, and Java performance tuning.
As your Java experience grows and you become a senior Java developer with more than 5-6 years of experience, it's expected from you to know both the big picture and the small details about Java's fundamentals.
If you can't profile an application or cannot figure out why it's slow or how to make it fast, then you should read a good book on JVM internals and performance tuning, e.g Scott Oaks' best seller Java Performance the Definitive Guide.
I have been reading it for years and still refer it whenever I get time. My goal is to read it again this year.
If you prefer online courses over books, then I suggest you take a look at Understanding the Java Virtual Machine series of courses on Pluarlsight, which explains memory management, class loading, Security, and Reflection.
Everyday Coding for 2 hours
Another thing I noticed last year is that as your experience grows, you spend your time on coordination, replying to emails, being a catalyst, troubleshooting, mentoring, and generally being a project manager kind of person.
What you left behind is coding, which is the single most important skill for a programmer.
If you feel that you are not doing enough coding, then make a resolution to code every day. At least, write something, be it on your project, an open source framework, a library, or a utility.
Since starting is the most difficult thing, I suggest that any time you feel resistance, start reading and refactoring code for fun. You will enjoy that and, in the process, you will also write code.
You can also solve problems given in Cracking the Coding Interview, 150 Programming Questions. This will not only make sure you're ready for an interview, but also improve your knowledge of data structures, algorithms, and programming logic.
Profile Your Java application Once a Month
This resolution is attached with the first resolution about reading a good book on JVM internals and performance tuning. Just reading the book will not be enough. You have to apply that knowledge in your live project.
I suggest you profile your Java application, at least once a month and spend a good amount of time understanding and analyzing the results.
You can also take a heap dump of your Java process or, if you had a recent crash, then take that heap dump and find out which object is taking most of your memory. Is there a memory leak in your Java application?
What is the cause? What will happen if other 100K new clients access your application? If you can answer all these questions comfortably, then you are in good shape. If you need some guidance on solving memory and CPU issues, I suggest you take a look at Understanding and Solving Java Memory Problems by Richard Warburton.
Participate in Coding Challenges
This goal is, again, somewhat related to our second resolution — write code every day for 2 hours. Let's face it, sometimes, you don't have enough chances in your live project to code.
If you are starving for challenging code, then there is nothing better than participating in programming and coding challenge.
There are many websites on the internet that host programming challenges and give you the opportunity to test your skills, but TopCoder is simply the best.
If you are looking for some tough programming challenges, then you can also check out my list of good websites to practice coding.
Learn Network Programming in Java
One more thing I have learned from interviewing people is that Java developers need to improve their socket programming and networking fundamentals.
I have asked many questions from my list of Java networking programming questions, but most developers fail to answer most of them.
Some of them even struggle to outline the key differences between TCP and UDP, which I thought was too basic to ask any Java developer of 2-5 years of experience.
If you feel that you have not gotten enough opportunity to learn socket programming in Java or that you don't need to because you are Java web developer working with JSP, Servlet, and JSF, then I suggest you read at least one good book on Java networking, NIO, and socket programming.
One book I highly recommend is TCP/IP Sockets in Java, Second Edition, Practical Guide for Programmers. It's easy to read, interesting, and a good way to learn the fundamentals of socket programming.
Java 9
The year 2017 saw a couple of big releases, and one of them was JDK 9. I have yet to start with JDK 9, but this is the first thing I am going to look into in 2018. If you want to learn new features of Java 9, e.g. Jigsaw, Reactive Streams, API enhancements, etc., then the Java 9 MasterClass is a good course to start with.
Spring 5.0
Another big release for the Java world in 2017 was Spring Framework 5.0. With lots of exciting features, e.g. reactive programming model and adoption of Java 8 and 9, Spring 5.0 adoption is going to speed up in 2018, and that's why every Java developer should learn it. If you need some help, Spring 5.0: Beginner to Guru is a good course to start with.
Spring Security 5.0
Another interesting release of 2017, which I am going to learn in 2018, is Spring Security 5.0. Spring Security 5.0 was a major release, and they rewrote a couple of modules and fixed several hundred bugs. The most interesting part is the OAuth 2.0 module. Unfortunately, there are not many resources to learn Spring Security 5.0 at the moment, but thankfully, Eugen has updated his Learn Spring Security to cover version 5.0 and also added a new module on OAuth 2.0.
Unit Testing
I Am Not A Robot Captcha Code In Java
If you want to become a better developer in 2018, then you should work on your unit testing skills. And not just unit testing, but automated testing in general. This also includes integration testing. You can learn JUnit 5 and other advance unit testing libraries like Mockito, PowerMock, Cucumber, and Robot to take your unit testing skill to next level. Mockito is really powerful and allows you to write a unit test for complex classes by mocking dependencies and just focusing on the objects under test. If you a beginner in unit testing and want to learn it in 2018, then the JUnit and Mockito Crash Course from Udemy is a good starting point.
Summary
That's my advice! If you are a Java programmer with a couple of years of experience, you can also take inspiration from this list to set your goal. Some other things you can add to this list are learning Android, Docker, and Spark, as those are essential for any Java programmers.
I have purposefully kept this simple and achievable because I personally believe that small successes lead to big successes. Setting small goals and achieving them is better than setting big, impractical goals and failing before kick-off.
So what are you waiting for? Write down your resolutions for the new year and share them with us. At the end of the year, you can come back here and tell us about how much you achieved.
Like This Article? Read More From DZone
Syntax
Flow Diagram
Example
Live DemoOutput
The if..else if..else Statement
-
An if can have zero or one else's and it must come after any else if's.
-
An if can have zero to many else if's and they must come before the else.
-
Once an else if succeeds, none of the remaining else if's or else's will be tested.
Syntax
Example
Live DemoOutput
Programming in Java.
We break the process of programming in Java into three steps:- Create the program by typing it into a text editor andsaving it to a file named, say, MyProgram.java.
- Compile it by typing 'javac MyProgram.java' in theterminal window.
- Execute (or run) it by typing'java MyProgram' in the terminal window.
- Creating a Java program.A program is nothing more than a sequence of characters, like a sentence, aparagraph, or a poem. To create one, we need only define that sequence charactersusing a text editor in the same way as we do for email.HelloWorld.java is an example program.Type these character into your text editor and save it into a filenamed HelloWorld.java.
- Compiling a Java program.A compiler is an application that translates programs from theJava language to a language more suitable for executing on the computer.It takes a text file with the .java extension as input (yourprogram) and produces a file with a .class extension (the computer-language version). To compile HelloWorld.java typethe boldfaced text below at the terminal. (We use the % symbolto denote the command prompt, but it may appear different dependingon your system.)If you typed in the program correctly, you should see no error messages.Otherwise, go back and make sure you typed in the program exactly asit appears above.
-
Executing (or running) a Java program.Once you compile your program, you can execute it.This is the exciting part, where the computer follows your instructions.To run the HelloWorld program, type the following in the terminal window:
If all goes well, you should see the following response
- Understanding a Java program.The key line with System.out.println() prints the text 'Hello, World'in the terminal window.When we begin to write more complicated programs, we will discuss themeaning of public,class, main,String[],args,System.out, and so on.
-
Creating your own Java program.For the time being, all of our programs will be just likeHelloWorld.java, except with a different sequence of statementsin main(). The easiest way to write such a program is to:
- Copy HelloWorld.java into a new file whose name is theprogram name followed by .java.
- Replace HelloWorld with the program name everywhere.
- Replace the print statement by a sequence of statements.
Errors.
Most errors are easily fixed by carefully examining the program as wecreate it, in just the same way as we fix spelling and grammatical errors when we type an e-mail message.- Compile-time errors.These errors are caught by the system when we compile the program, because they prevent the compiler from doing the translation (so it issues an error message that tries to explain why).
- Run-time errors.These errors are caught by the system when we execute the program, because the program triesto perform an invalid operation (e.g., division by zero).
- Logical errors.These errors are (hopefully) caught by the programmer when we execute the programand it produces the wrong answer.Bugs are the bane of a programmer's existence.They can be subtle and very hard to find.
Input and output.
Typically, we want to provide input to our programs:data that they can process to produce a result. The simplest way to provide input data is illustrated in UseArgument.java.Whenever this program is executed, it reads the command-line argument that you type after the program name and prints it back out to the terminal as part of the message.Exercises
- Write a program TenHelloWorlds.javathat prints 'Hello, World' ten times.
- Modify UseArgument.java to make a programUseThree.java that takes three namesand prints out a proper sentence with the names in the reverse of the order given, so that for example,'java UseThree Alice Bob Carol'gives 'Hi Carol, Bob, and Alice.'.
Web Exercises
- Write a program Initials.java thatprints your initials using nine rows of asterisks like the one below.
- Describe what happens if, in HelloWorld.java, you omit
- main
- String
- HelloWorld
- System.out
- println
- Describe what happens if, in HelloWorld.java, you omit
- the ;
- the first '
- the second '
- the first {
- the second {
- the first }
- the second }
- Describe what happens if, in HelloWorld.java,you misspell (by, say, omitting the second letter)
- main
- String
- HelloWorld
- System.out
- println
- I typed in the following program. It compiles fine, but when I executeit, I get the error java.lang.NoSuchMethodError: main.What am I doing wrong?Answer: you forgot the String[] args. It isrequired.
Copyright © 2000–2019Robert SedgewickandKevin Wayne.All rights reserved.
java.awt.Robot
. The bot works fine on a browser (I have also tested it using Microsoft Word!) but when I run it in the game, the only function that works is the mouseMove
. I want to build a bot that simply presses keyboard buttons for me.
2 Answers
r.delay(1000)
statement, the bot did two instant actions.
I Am Robot In Java Full
bot.delay(500)
(or more, depends on the game) right after you instantiate Robot class; before all the key pressing functions. That would add a 500ms delay between ALL actions done by the robot.