3

Example with a context:

No matter what kind of value you are working within Java, you can typically output that value as a string, simply by concatenating it to some other value. To demonstrate this, I have declared eight variables, one each of the primitive data types, character, Boolean, byte and so on. Each of these is using a literal value as its initial value. Now I'll place the cursor after the declarations and use System.out.println and first I'll output the character. I'll save and run the application and I get the letter z, that's pretty expected.

Why not simply say I have declared eight variables, each of the primitive data types? The phrase one each grammatically sounds a little bit off to me. That means that there's probably something I don't understand. What do you think?

  • should be "with in" not "within", BTW. – Tᴚoɯɐuo Apr 3 '15 at 13:53
  • 2
    I would have written "one for each of the primitive datatypes..." I think the author was thinking of this usage: Here are some pencils for the students; give them one each. – Tᴚoɯɐuo Apr 3 '15 at 13:55
  • 1
    @TRomano no, that would be wrong. The variables are not for the data types they are of the data types, hence the omission, just as in your correct example. Explicitly writing one of each would certainly be easier for most non-native speakers, though, perhaps that could be an answer. – Please stop being evil Apr 5 '15 at 17:55
  • @TRomano also that example is for a different usage of "one each" which would be replaceable with "each one" in that case. – Please stop being evil Apr 5 '15 at 20:44
  • 1
    @the dark wanderer: it would not be wrong to say "Here are 50 city names, one for each of the 50 states -- match the city with the state of which it is the capital". In the same way, if there are eight datatypes, one could say "I have declared eight variables, one for each of the eight primitive data types..." – Tᴚoɯɐuo Apr 6 '15 at 1:06
0

This usage is correct and precise.

It indicates that there is exactly one variable declared of each type. So the sentence

To demonstrate this, I have declared eight variables, one each of the primitive data types: character, Boolean, byte and so on.

tells you that there are eight variables, they are all different primitive data types, that all of the primitive data types are represented, and that therefore there are eight total primitive data types.

Your alternative sentence

To demonstrate this, I have declared eight variables, each of the primitive data types: character, Boolean, byte and so on.

has less information. It says that there are eight variables, and each of them is one of the primitive data types. It does not say that all eight variables are different types, how many types are in use, or how many types exist. This is because it does not say how many there are of each type.

Alternative Phrasing

If you don't like that phrasing, there is an alternative one you can use:

To demonstrate this, I have declared eight variables, one of each of the primitive data types: character, Boolean, byte and so on.

To me that sounds a little awkward and forced, but I wouldn't suggest that it is 'incorrect'.

If were were talking about something other than variables and types, then using 'for' would make sense rather than 'of', but the particular relationship between variables and types requires using 'of'. Variables are 'of' a type, not 'for' a type.

List Notation

I agree that the list should be preceded with a colon in this instance, but I don't think that it impacts understanding or meaning, and is therefore not that important.

|improve this answer|||||
0

It is correct. "Each of the primitive data types" indicates that they are all primitives but not that that all primitive types are represented exactly once. "one each" indicates that you have one of each primitive type. In general "one each" may be replaced by "one of each" with only stylistic damage. The comma after "primitive data types" is wrong and confusing, however; it should be a colon.

It is worth noting that your example is also excellent for illustrating what the difference between "one of each" and "one for each" is and why this is important. If the author had written "one for each", the 'one' would refer to some kind of container for holding data of one of the primitive data types. By saying "one each" which here means "one of each" the author deliberately makes no distinction between the allocation of memory for some given data and a variable of that kind of data-- which is canon for modern exception-safe high-level programming. For further programming-specific information on the importance of this distinction, see Resource Acquisition Is Initialization.

It is also worth noting that there is another common use of "one each" which is separate and distinct from this one. Example:

We have some leftover pancakes, but not too many. I think there's enough that we can have one each.

Here "one each" means "each have one". This use is exclusive to distributing things among a group.

|improve this answer|||||
-1

Given that the author is refining the nature of the "eight variables" being declared, and that refinement is specifically to point out a definition for each of the primitive data types (and there are eight), "one for each of the primitive data types" is the correct choice. Further, as the author is introducing a list of the types, "...primitive data types" should be ended with a colon preceding the list, not a comma.

In summary, I would offer this rewrite:

"To demonstrate this, I have declared eight variables, one for each of the primitive data types: character, Boolean, byte, and so on."

|improve this answer|||||
  • No. It's one OF each, not one For each. One for each has to be explicit one of each permits omission. – Please stop being evil Apr 5 '15 at 17:52
  • And he did declare one for each type. Eight variables, eight types. There is no omission. – David W Apr 5 '15 at 18:44
  • 1
    "permits omission" as in the word 'of' can be omitted. He didn't declare one for each variable as to say that you did something on behalf of the variable would be very strange. You can do/produce things for inanimate objects, but in this context that isn't what's happening. The declared variables are variables of the primitive types of data (see en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization) not just containers for that data. Ordinarily you would just be wrong in a way most people think doesn't matter when you use 'for' here, but in this case it's important. – Please stop being evil Apr 5 '15 at 20:33
  • 1
    The essence of the semantic debate here is the declaration of the variables. The variables declared were obviously "of" a type, but the purpose was for an illustration of common behavior among all types. They were declared for all types to show universal behavior. – David W Apr 5 '15 at 20:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.