Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 639193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:48:55+00:00 2026-05-13T20:48:55+00:00

I usually end up trying every combination until it compiles. Can somebody explain what

  • 0

I usually end up trying every combination until it compiles. Can somebody explain what I should use where?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:48:56+00:00Added an answer on May 13, 2026 at 8:48 pm

    I’ll disagree with Chris’s answer in one regard. The classes Any, AnyRef and AnyVal are classes. But they don’t appear as classes in bytecode, because of intrinsic limitations of the JVM.

    This arises out of the fact that not everything in Java is an object. In addition to objects, there are primitives. All objects in Java are descendant from java.lang.Object, but primitives are set apart and, presently*, not extensible by a programmer. Note also that primitives have “operators”, not methods.

    In Scala, on the other hand, everything is an object, all objects belong to a class, and they interact through methods. The JVM bytecode generated does not reflect this, but that doesn’t make them any less so, just as Java has generics, even though the bytecode doesn’t have them.

    So, in Scala, all objects are descendant from Any, and that includes both what Java considers objects and what Java considers primitives. There’s no equivalent in Java because there is no such unification.

    Everything that is considered a primitive in Java is descendant from AnyVal in Scala. Until Scala 2.10.0, AnyVal was sealed, and programmers were unable to extend it. It should be interesting to see what will happen with Scala on .Net, since interoperability alone calls for Scala to at least recognize user-defined “primitives”.

    Also extending Any is AnyRef, which is equivalent to java.lang.Object (on the JVM at any rate).

    Up to Scala 2.9.x, a user could not extend Any or AnyVal, nor reference them from Java, but there were other uses they could be put to in Scala. Specifically, type signatures:

    def f(x: AnyVal) = println(x)
    def g(x: AnyRef) = println(x)
    def h(x: Any) = println(x)
    

    What each means should be obvious from the class hierarchy. Of note, however, is that f and h will auto-box, but g will not. That is a bit the opposite of what Java does, in that f and h cannot be specified, and g (defined with java.lang.Object) would cause auto-boxing.

    Starting with Scala 2.10.0, though, the user can extend AnyVal or Any, with the following semantics:

    • If a class extends AnyVal, no instance will be created for it on the heap under certain conditions. This means the fields of this class (on 2.10.0 only a single field is allowed — whether that will change remains to be seen) will stay on the stack, whether they are primitives or references to other objects. This allows extension methods without the instantiation cost.

    • If a trait extends Any, then it can be used with both classes that extend AnyRef and classes that extend AnyVal.

    PS: In my own view, Java is likely to follow C# in allowing “struct” primitives, and maybe typedefs, as parallelism without resorting to them is proving difficult to accomplish with good performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my applications I always end up implementing a Model-View-Presenter pattern and usually end
I have written a few Excel 2003/2007 add-ins using VSTO, and I usually end
I usually either end up using [range]%s/word/another_word/gc or do it manually. I wonder if
When I have to render textarea content to the front end I usually pass
Sometimes in case of a bug in our code, we usually ask the end
I usually edit RUBY files in VIM. I want the methods(def...end) to fold. Could
Usually Flash and Flex applications are embedded on in HTML using either a combination
I'm in the U.S., and we usually format dates as "month/day/year". I'm trying to
I am trying to use this code for the Porter stemming algorithm in a
I'm trying to understand the IntentService class so that I can build my own

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.