Liutauras Vilda

Sheriff
+ Follow
since Nov 12, 2014
Liutauras likes ...
BSD Linux Mac OS X VI Editor
Forum Moderator
London, United Kingdom
Cows and Likes
Cows
Total received
466
In last 30 days
2
Total given
1500
Likes
Total received
1405
Received in last 30 days
7
Total given
1423
Given in last 30 days
34
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Liutauras Vilda

Could you please rephrase your question? Currently quite a few people may find it difficult to understand.
17 hours ago

This one on the other hand take the last number and multiplies the last number in the array by two:


The method's name above also perhaps requires some tweak.

Read out loud what you described the method supposed to be doing, and read also out loud method's name. Do they communicate the same idea behind? Not to me personally. While reading the description I could imagine the implementation, but looking to method's name I don't even understand what that means.

"Get numbers for sums..." - very weird, isn't it? Or "Get numbers for sum s..." ? Not clearer either.
1 day ago
@OP

As been mentioned from other aspect, try to be very precise on what you are saying and what you are doing. For instance the subject of the topic is "Summing arrays". Really you can't sum an array. What you actually can do, is to sum elements of an array if they appear to be numbers in some sense.
1 day ago
@OP

I think forget about your initial topic, at least in the way it was presented to you, because it causes no end confusion. I'd say analogs were chosen poorly, which in turn confused you.

When things get complicated, and difficult to explain, I usually try to find some silly examples which may or may not closer to real life examples.

Here's one:
1. Think of an array as an already built toolbox, which can hold either a set of hammers, or bunch of screws, or bunch of pliers or similar tools of one kind. That is how it was built and that is it.
2. Think of an object as a thing, which can be built to be a: either toolbox, or house, or phone, or car, or... anything what you could think of as a model from let's say real life.

So an array is already pre-built and could not be modified - so it serves a purpose of storing something. It is an object. Probably would be easier to think that everything is object, except few primitive types in java such as: booleans, ints, longs, chars, bytes...

Consider object as a material, which gets its form when is assembled based on needs. So if you need it to be able to store several different kind values in it, yes, you can configure it in such way so it could do that. If you need it so it couldn't store any value in it - you can make it so too.

Arrays in Java are being declared in such way as an example:

So such array would be able to hold 4 car objects in it. An array is denoted as [] in Java. Car on the other hand, is a type of object an array can hold.

Now, how such Car object definition may look like:

As you see, I defined how my Car object will look like, meaning, what kind of information it will hold. So it will have its make, it will store its current speed. Make and Speed as you see are of different type, obviously... So I made it in the way it makes sense to me, which is going to be used in my hypothetical program.

So such object gets instantiated in the following way:

If you remember, I've declared one method in it, which is increaseSpeed(), so I can call it:

With an array on the other hand, you can't define methods yourself, because it was built already and most importantly, NOT BY YOU, so you have locked ability to add anything else than what was added by the guys who implemented presumably Java language. And as you saw, an array has "[]" this thing, which you don't use when you create object, so that is also a specific array's thing, which I don't think you need to know anything more about it (same as I).

And so really that is it I think.

What confuses you from all that?
4 days ago

Hari Nagarjuna wrote:

Arrayobject
It can only store one datatype variablesIt can only store multiple datatype variables
It cannot execute methodsIt can execute methods



If you had to choose from those 4 sentences and put them in the corresponding table columns/rows - it is fine, but in general I find it unnecessarily confusing as for descriptions.

When we say about object "It can only store multiple datatype variables", I end up being confused, so it cannot store singular datatype variables? It can't do anything else? Those questions don't require answer, but just shows, how I would be confused reading in a book about object presented in such way.
4 days ago

Dave Tolls wrote:Does APress do their ebooks via an account?


I'm not sure. Book promo team probably would know.
6 days ago
Hi Randy. As far as I recall, e-books quite often are being received as downloadable items from publisher's page.

For instance fairly recently I won the book X, so I got an email from publisher, that I need to go on their website and enter 100% discount code and so the book gets into my account from which I can download it at any time. Hm.. could be that such process is tight to publisher.

Let's wait until someone from book promo team reads your message, so they possibly could provide you with more details.
6 days ago

Stephan van Hulst wrote:...except move the parameter checking and the defensive copying to the factory methods. Private constructors may assume that their parameters are validated and copied,


Well, yes, I missed few important details, the idea was to raise the point about factory methods. I think that constructors supposed to take care of validations and not the factory methods.
6 days ago
Stephan, very nice code two posts above.

I just willing to mention a slight improvement which could be made in order to avoid no-args constructor to better convey a result of such wallet's instantiation. In my opinion a static factory method(s) would fit here nicely, i.e.:


So API's use would read as:
6 days ago
Welcome to the Ranch. What a surprising book here. Have a great week along with bunch of questions!
Michael, hi.

What the output supposed to be if the matrix were:
A  A  A  A
Z  Y  X  W
X  A  D  F
G  V  X  G

>?
1 week ago
That thread seems to be very sturdy so it can hold the cow 90° anticlockwise. Surely can't be picture rotated.
1 week ago
We have noticed, not randomly, not even pseudo-randomly, that:

Al Hobbs

and

Jay Rex

Have been consistently helpful on the CodeRanch forums. We were so exited, so decided to award them with the Rancher titles.

All, please join us in congratulating them.

The crew of two! Thank you for your contributions to these forums and congratulations on the new titles.


----
What does the Rancher title mean?

This page http://www.coderanch.com/how-to/java/SaloonTitles has a brief description about it. Unlike the moderator titles (like Bartender, Sheriffs etc...) which have super powers associated with them, the Rancher title is more a token of appreciation for the members' contributions. However, the one notable power that a Rancher title brings in, is the ability to award cows to fellow members. So whenever you see a post which deserves a cow, please do make use of your powers and award them.f
1 week ago
I have suspicion, that OP wants to know a bit more how actually the uniqueness is achieved across the globe (in simple words saying).

How the identifier is obtained, for instance: is the current time taken in consideration, date, maybe some local machines hardware figures, etc, etc...

@OP
Is that what's you worrying?
1 week ago