Anupam Jain

Ranch Hand
+ Follow
since Mar 16, 2010
Anupam likes ...
Eclipse IDE Java
Merit badge: grant badges
For More
Delhi, India
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Anupam Jain

Ricky Long wrote:On Project Explorer, if you minimize the class to hide the methods, then the problem goes away. You still can have both "Toggle Mark Occurrence" and "Link editor with Explorer" selected. Not a solution, but at least a way to avoid getting annoyed.

Yup.. Ricky's solution worked for me... and no need to disable the linking arrows (Really useful for me)

Hello Everyone,

I'm using jxl API : jxl-2.6.10.jar and have following line(s) of code in my project:

While the above code runs fine for a number of cases, the second statement is giving following exception in few cases (no specific case characteristic to separate out such cases from others).

I've been trying to resolve this for like hours now... search the whole Google may be... Found the following link of some IRC logs discussing this problem but without any solution...
URL (Look for the name 'thinkstu')

Has anyone seen this kind of problem with the jxl API before? Please help..
12 years ago

Martin Vajsar wrote:
I've personally resolved this issue by implementing my own logger (it calls log4j in turn, of course). The important part is here:

The message is passed to the logger as a String plus an array of references (causing an overhead I'm really not going to care about), and is formatted only when the logger is active. Regardless of how expensive the logged object's toString() method is, it is evaluated only when needed.

Note: I'd like to make findbugs check the formal parameters of the debug method in the same way it checks the String.format() invocations, but I didn't find time to delve into the modifications yet.

Thanks Martin. This strategy certainly resolves my primary concern.
12 years ago

Joanne Nea wrote:
Why do you want to do this ? Have you seen that the the calls are causing a performance problem or are you just assuming that they will ?
Unless there is a demonstrable performance problem due to these calls then you shouldn't worry about them.

There definitly is a performance hit with all these call present in the code when the logs aren't actually getting printed.
For example let's say we have a logger call as follws :

Now even when the logger level is not debug, this statement would cause the String object creation and then appending the value of var to occur.
I guess you've got my point.
12 years ago

Wendy Gibbons wrote:please could you provide a concrete example of why you are trying to do this, as I am completely stumped about what you are trying to achieve.

instead of calling the method that has been written in the code, you want to call another method completely?
so instead of calling Wendy.hello() you want to call fred.confused()
but you want this being controlled at runtime not in the code?
couldn't you just..

the if-else style would certainly resolve the issue... and this really is something which I want to achieve but not with the use of the if-else construct itself.
As a concrete example... I would like to suggest the usage of log4j API.
We heavily use this API in our code for logging purposes. And as you might be aware... we can control the level of logging as debug/info/warn/error etc.
This can be done by specifying the level in file.

Now suppose we've set the level to info/error... but there would be a lot of debug calls present in the code.
In such cases, even though the debug logs would not be printed, but the calls themselves are entertained and only inside the method is it checked whether the log is to be printed or not.

For such cases I would like to bypass the call itself if the level is not debug. This can be done with if-else but that is not a feasible solution when we have a lot of debug statements present in the code.
12 years ago
Do we have any mechanism in Java by which we can bypass/interrupt a method call?
For example, Say we have a static method in some class Utility.sampleMethod().

Call to this method may be present in many other classes in the project.
Now in some/all of them, I wish to jump to some other method whenever I see this method call... Is it possible in Java?
12 years ago
As far as I can see and Understand... they all are valid...

What's your problem exactly?
Hello everyone,

I was looking for some cool solutions for producing some chart/graphs from java (Other than JFreeChart), And the promises that this project made, quite caught my eyes...

Though they propose to support Java as well... but I could not find any real examples/ tutorials for using this project in Java.

Can someone help me out on how to use this project. Any tutorial or help would be great...

13 years ago
You may also want to check usage of FileWriter

This would be better useful when you need to take some decisions while writing to the file.
13 years ago

Steve Hall wrote:
Why then would you want to make an array that can contain multiple types? I mean it seems useful at first. I could have an array of electronics that contains televisions, computers, phones and so forth. But if I can't call the methods of these specific types why bother? In normal implementation do you cast it as the appropriate type every time? I could see this leading to mismatching problems pretty easily unless you are very careful.

I think I have the what happens part down I just am not sure about the reason why this is useful, why would I ever type a subclass object as a superclass if i can't access it's methods.

Hello Steve,

Let's try to consider your problem in some real world scenario (separate from the programming thing).

Suppose you want to make your Electronics array function like a Universal Remote Control for your home, so that, it can turnOn() or turnOff() every electronic component in your house.

Now for this a single array is required, while the actual implementation for turnOn() and turnOff() would reside in individual classes which would be invoked appropriately according to the Object in Electronics array at run-time.

I hope this scenario should clarify you something...
13 years ago

Halley Thomas wrote:
It means there is no improvement in performance if use the += operator if I have two variables, right?

Yeah right... I found the same thing when using another variable b.

But try replacing b with some constant number say 1 or 2. You'll see the difference then...
13 years ago

Halley Thomas wrote:Which is better?




Can you please explain why also?

As far as I've found out and understood...
While incrementing by a variable as above... They are both same.
But if you are incrementing by some constant value say 1 like this :

i = i + 1;


i += 1;

Then the later one is more efficient...

This can be explained by using javap command..

javap -c <class name>

13 years ago

marc weber wrote:

abalfazl hossein wrote:...
May you explain about this output:
[1, 2, 3, 4]

I have no idea. That does not appear when I run your code.

Yup, It doesn't appear to me either...
13 years ago

Ernest Friedman-Hill wrote:
Anyway, despite that website's claim that NaviCoder is powerful and popular and wonderful, I've never heard of it, and the online manual makes it look positively dreadful. There are many better choices available -- don't torture yourself trying to make this toy IDE work if it's preventing you from doing something as simple as adding command-line arguments to a program. Eclipse, NetBeans, or for beginners, BlueJ (all these are easily Google-able) are industry standards and are all fine pieces of software.

Yup, I didn't heard of this NaviCoder as well.
Eclipse is more than enough for me...

Rakesh Ss wrote:Hi,

How do we pass command line argument, when we are executing through IDE.
Currently I'm using NaviCoder IDE.

Thanks in advance,

Haven't tried NaviCoder. I use Eclipse instead... There is an option of Run configurations under Run menu. It also appears under Run As of the menu that appears on right-click of the main class.
Under Run Configurations go to tab arguments. here you can specify the command line arguments for your program.

See if there is anything called Run Configurations in NaviCoder as well.