Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!

Junilu Lacar

+ Follow
since Feb 26, 2001
Junilu likes ...
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
Forum Moderator
Junilu Lacar currently moderates these forums:
Columbus OH
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 Junilu Lacar

I would think that has something to do with a method defined by an interface. Is DataParser an implementation of an interface? When you choose "declaration" where Eclipse take you? Where did it take you when you choose "implementation"? 
1 hour ago

That's pretty typical from my experience. Did you do a quick retro after the session?  Next time, try to and bring up the concern that people are not engaged or are doing things not related to the work being mobbed on. Then put something in your team working agreements. It could be that you all agree to leave phones in a basket. Or no other computers besides that mobbing computer.  Or to set aside the mobbing time as "busy" on their calendar.  There's all kinds of things like that you can get people to agree to. Just don't keep quiet and stew on it if you feel it could be better. It's always about getting better so bring it up if you know a way that might help.

Vaibhav Gargs wrote:As per my understanding, the strings created using literals i.e. without using new operator will be allocated in String pool. Here we are not using new operator to create strings, so, won't they be created in string pool.

You seem to have contradicted yourself there.  The string literal "hello" will be in the String Pool. "hello" + i is a String expression; it will not be put in the String pool.
3 hours ago

Daniel Demesmaecker wrote:... And I was always told to eliminate the need for a variable where possible, if there wouldn't be an instance variable size, there would also be no confussion about which one to use...

Always consider context. There are times when a variable isn't needed, there are times when it helps clarify the code. It just depends on the situation so don't apply a rule just because "that's what you were told to do." Know the reasons why and why not.

Who was that chalenge actually for?

I believe that was an example from a book. Examples tend to focus on a certain concept. This one didn't care so much about the other things you pointed out. Again, it's context-based. Should you do this in a real-world program? No. Is it enough to demonstrate a concept? Probably. Is it good way to do that? Maybe, maybe not. It depends on who you ask. (There it is again: context)
6 hours ago

sonai kale wrote:This should be used only when you want to build different immutable objects using same object building process.

Where did you get this from? Builder is NOT restricted to the creation of immutable objects. See Builder Pattern
21 hours ago
Welcome to the Ranch, Vincent!

How it works around here is that you have to show what you did or give what your answers are or say what is confusing you and we can give you feedback or guidance. We won't give you answers outright or write code for you.
2 days ago

Reg Armstrong wrote:It is getting late for and old man, all I will say on this I am on the wrong side of '50'.

Since you're from down under, I take it you mean "less than" when you say "wrong side of". Up here in the Northern hemi, we're just getting started when we get to the big Five-Oh.
2 days ago
The discussion is a bit disorganized. He dives down into details like heap and memory management when it probably would have been better to expound on more high level concepts and giving context to why you'd want to take an object-oriented perspective versus a procedural one.
2 days ago

sowmymo sandy wrote:how to write a java program to arrange the elements in even position first followed by elements in odd positions

Welcome to the Ranch!

When posing a question, try to provide as much context as needed for others to understand what it is you're dealing with. To simply say "arrange elements" like that is very vague. Elements of what? An array? A List? What kind of object or data structure are you referring to here? Better yet, show us the code that you wrote (and remember to UseCodeTags ←click that link)
2 days ago
Considering it was the fifth chapter and a number of basic programming concepts had been already been introduced in previous chapters, I thought the discussion about objects wasn't bad. I didn't get the impression that prior knowledge about object-orientation was assumed. I was a bit disappointed that the author used Math.random() instead of java.util.Random. In fact, that would have been a good opportunity to give an example of the difference between a procedural subroutine vs. an object method.

Edit: Spoke too soon. Actually, he does talk about java.util.Random in section 5.3
2 days ago
char is already an integer type so you don't need a cast, you can assign chr directly to a. A widening conversion is automatically done.
3 days ago
Welcome to the Ranch!

There are many sources of information online and there's little reason for you to rely solely on your official course material. I suggest you check out the Official Java Tutorial. Go to your local library and borrow some beginner-level books on Java. While you're there, see if you can find good introductory book on programming in general.  I like Think Like a Programmer: An Introduction to Creative Problem Solving by V. Anton Spraul. It's not in Java but some of the concepts he discusses about problem solving techniques are just as easily applied in Java.

If you're a visual learner, then the Head First Java book by Kathy Sierra and Bert Bates is frequently cited and discussed around here. I personally like Bruce Eckel's "Thinking in Java" which is a bit dated but still mostly relevant. He also has a newer book On Java 8 which is available for purchase online in the Google Play store.

So, as you can see, there are plenty of options for additional reference material.
4 days ago

David McCafferty wrote:Would I be right in thinking that (double price) is an argument?

It's called a parameter. More specifically, it's called the formal parameter. The value that you pass to the method when you call it is called the actual parameter, sometimes also referred to as the argument.

I don't get why it is directly after the findTotal method after it has already been declared.

Assuming you're referring to the price that is declared on line 6, that is a different entity from the price parameter declared on line 8. Within the findTotal method, an unqualified reference to price will resolve to the parameter. The price field on line 6 is said to be "shadowed" by the price parameter on line 8. If you want to refer to the price field inside the findTotal method, you have to refer to it as this.price.  As it is, you don't need to refer to the price field because you have all the information you need to calculate the total.

I suggest you look through the Java Tutorial on Member Variables (also known as "fields") and the Java Tutorial on Methods. Don't rely on just your course materials.
4 days ago
I have a slightly different perspective on using and not using IDEs to learn Java. 

IDEs hide a lot of the nitty-gritty details and plumbing that you have to deal with when you're working at the command line. For me, working at the command line and in a text editor like NotePad is like learning how to drive a stick shift. It gives you a better understanding of the inner workings of the machine you're trying to drive.

1. You can better understand how packages, paths, and classpaths work in relation to the java command.
2. It forces you to be more disciplined in formatting your code properly.
3. It forces you to understand the flow of logic and control and think like a compiler.

All these are good things and I think they helped me develop good skills as a programmer, just as learning how to drive a manual transmission probably helped me be a better driver. At least that's what I told my kids when I forced them to learn to drive stick.

IDEs, however, take a lot of the tedium out programming. You have code completion, auto-formatting, assisted refactoring, quick navigation, and keyboard shortcuts that can make you much more productive. Of the three that I listed above, I think the first one, understanding how packages, paths, and classpaths work is the main benefit. The other two you could probably learn just as easily with an IDE if you practiced and learned intentionally.

For example, if you wanted to develop a discipline for formatting your code properly, you can still use an IDE and write code without using its autoformatting feature first. Then, at regular intervals, invoke the auto code formatting feature and see what the IDE corrected in your formatting. Study what the difference was between how you formatted the code and how the IDE formatted the code. Then learn from that.  It helps if you use a version control system like Git or Subversion so that you can examine the differences before and after autoformatting.

As for understanding the flow of execution, most IDEs allow you to debug and step through your code as it gets executed. I would use this in much the same way as with learning how to properly format code. First try to visualize the flow of your program logic yourself to form an opinion of how your program will behave. Then, if the program doesn't behave quite how you thought it would, use the debugger to walk through the program and understand exactly where you misunderstood the flow.

If I had to learn Java all over again with the tools available today, I'd probably work on the command line and in a text editor for about a week. After that, I'd probably want to switch to an IDE to relieve myself from all the tedium and really focus on the concepts that I need to learn rather the mechanics of running programs and all that other stuff you have to deal with yourself on the command line.
5 days ago