Jeff Verdegan

+ Follow
since Jan 03, 2004
Jeff likes ...
Android IntelliJ IDE Java
Merit badge: grant badges
For More
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 Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeff Verdegan

Jeffrey Schmitt wrote:Seems a bit round-about

Not really. It's just a very general solution. You can search for any type of object, using whatever sorting and equality rules you want. So you have to provide the information necessary to determine a match--an object with the appropraite fields set.

so I sort of feel like just using my own binary search was better

Maybe it was, for your particular requirements for this particular use case.

but maybe the Collections search is optimized beyond what a Java programmer could do.

Nope. It's just normal Java code written in exactly the same way than any other Java programmer could write code. You or I could very easily implement that method the same way as what's in the API if it weren't there.
11 years ago

kaden welch wrote:but i dont know what he means with 2 modifcations

Then it would make much more sense to ask him than to ask the forum. Especially since none of us here knows the original requirements, so we have no context against which to evaluate what might be meant by those modifications.
11 years ago

Prajakta Acharya wrote:
Firstly,I am an experienced Java developer who has extensively worked on various development projects and I have consistently proved my development abilities.
I have worked on many new frameworks which were new to me and have enough confidence that I can grasp new things on job.

Then that's what you should tell the interviewer, along with, "While I don't have any direct experience with multithreading, when I learned that it was important for this job, I started studying it. I expect to be able to come up to speed quickly, although I may need some guidance initially."

Secondly, I am already employed and was preparing for a client evaluation.

Okay, but that's not relevant to anything I said.

In my opinion, it is not always possible to have hands on on each and every framework and there is first time for everything. That should not stop you from aspiring for a good project.
It is the responsibility of the employee to keep sharpening the saw, as far as technology is concernced and I am already aware of these things.

I agree completely. But that doesn't mean you should try to come off during an interview as more knowledgeable than you really are.
11 years ago

Shelby Simpson wrote:I was wondering why it would matter if I put public or private in front of a static method or variable. There a class variable and method so does it matter?

Why do you think it's any different marking a member variable public or private if it's static vs. non-static?

The access modifiers are orthogonal to static vs. non-static. They have the same meaning regardless of whether the member in question is static or not.
11 years ago

Sur Chawla wrote:What will happen if I have a return statement at the end of try block if
1)there is an exception?
2)there is no exception?

Try it and see.
11 years ago

jv patel wrote:Hello everyone,
in the code, why using double sync check on map instead of using enum for singleton design pattern

I assume you mean "Double-checked locking". There is no reason to ever use DCL in Java. In fact, before 1.3 or 1.4, the memory model allowed that idiom to fail. I can work in later versions, but there's still no reason to ever use it. I may give very, very small performance gains in lazily instantiated singletons, but there's no reason to lazily instantiate a singleton anyway.

Just forget DCL exists entirely. It's broken and useless.
11 years ago

Matthew Brown wrote:

Stephen Black wrote:The bitwise operator can solve the problem
if ((number & 1)==1)

You can do that, but it's a method that will be less familiar to most people, especially beginners. I'd suggest if (number % 2 == 1)

Not only that, but if you want to generalize "even/odd" (which really means "divisible by 2 / not divisible by 2") to other cases, such as "divisible by 3 / not divisible by 3", then if you're using the % operator as Matthew suggested, it's a trivial change.
11 years ago

Ryan Cridelich wrote:I'm confused as to why I need to list those variables there to begin with, or what their purpose is supposed to be,

They're parameters. Do you understand how parameters work in methods and constructors?

If you wrote the VideoGameRating class, then you know what you're doing with them in its constructor and why they have to be there. When you're constructing a VGR object, you're telling it what its name, number, etc. will be.

It just says that the actual and formal argument lists differ in length. What is says is required is String, and four doubles, but found nothing.

That's quite explicit and to the point. It's telling you exactly what's wrong. When you invoke that constructor, you have to give it that information, but you're not providing it.
11 years ago

Ryan Cridelich wrote:
I have all of those variable initialized at the top of that class.

No, you don't. You've declared them, but you haven't initialized them. Member variables get default values, but locals (which this are) do not. They don't have a value until you assign one to them.

So you declare the variables, they don't have any values defined, and then you go into the loop and do:

What value do you think you're passing for gameName there? How do you think it got that value?
11 years ago
If you're cramming at the last minute before an interview, you are in effect trying to deceive the interviewer into thinking you are more qualified for the job than you actually are. If your answers manage to impress him enough to land you the job, then what? You won't actually have learned and come to understand the topics enough to do the job just from the cramming, and now you're getting paid to do a job that you're not competent to do.

It's fine to brush up on stuff that you're familiar with but have forgotten the details of, but it is a disservice to the employer, to other candidates, and to yourself to pretend you know more than you do, not to mention being highly unethical
11 years ago

Krishna Chhabra wrote:Not able to understand exactly that what does (this) means in below code

It's telling us which lock we're going to obtain. The only thing that the synchronized keyword does¹ is to obtain the lock for the indicated object, blocking at that point in its execution until the lock is released if some other thread currently hodls it. That's all. When we do synchronized (this) that just means we're obtaining the lock for the "current" object.

¹Actually that's all it does in terms of mutual exclusion. It also provides some memory barrier effects for consistency and predictability of the values of shared variables, but that part isn't pertinent to your question.

Mauro Trevigno wrote:
if(Day == 1 || Day == 7)

Don't use those magic numbers. Use the appropriate contsants instead.
11 years ago

Chris Bremer wrote:In my Cattle Drive OOP-3 method LastNameCompare, I implement Comparator yet I don't override the equals(object obj) method. I am referencing a java book that says when you implement an interface, all methods associated with it must be overriden...can anyone clarify this for me?

If it truly says "all methods associated with it must be overriddent," then it's a poorly written book indeed.

The rule is that a concrete class cannot have any abstract methods. All the methods defined in an interface are implicitly abstract, so any class that implements the interface must provide implementations for those method--or else itself be delcared an abstract class.

HOWEVER, your class already provides an equals() implementation. Every single class does, by virtue of the fact that the inherit it from Object. So if you don't provide your own equals() method, you'll just use Object's; two distinct Comparator objects will never be equal in that case, Comparator explicitly names equals() even though it's not necessary in order to provide documentation about what equality is intended to mean for Comparators. It even says right there in the docs, "it is always safe not to override Object.equals(Object)."

And do note that the equals() method is for equality of Comparator objects, not of the objects they're comparing.
11 years ago