Posted by: ahmedashfaque | July 26, 2017

Software programming – a challenge?


Recently I was working on a project and came on a peculiar problem. I had a single character value coming from method and needed to check its value in another method inside another class.

In Java, there are 2 types of variables dealing with strings. One variable deal with only one character. The other variable deals with strings consisting of more than one character. Generally the string variable type should also be handle single characters. This is the general common sense. But not so in Java.

I had this single character variable value coming from a JSP (Java Server Pages) file. I had to check this value inside a compiled Java class file. I had defined a variable of string type in JSP file and in JSP there is no problem. So I had also defined a variable in my Java class as a string type to check its value.

This program was part of a dynamic web project. I was using Tomcat as the application server. When I ran the program to test i was getting a null pointer exception error in the program. I checked from where this error was coming. I found that the program was not correctly evaluating the checking of the character variable and thus wrongly executing the next piece of code and giving error.

So I had to change the variable type to character from string. When I ran the program, this time it was not giving error.

Programming in any case is not easy even when you have all the tools to debug and test and get error description. Even when your logic is correct, your program may not run correctly due to these small compiler problems and you need to be careful.

Advertisements

Responses

  1. Thankyou for wonderful article. It has more Information in Your Website sap video tutorials.

  2. Fabulous..!! Thank you.The information you provided is much usful information on sap video tutorials.

  3. Thankyou for wonderful article. It has more Information in Your Website sap video.

  4. Fabulous..!! Thank you.The information you provided is much usful information on sap video.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: