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

Ask A Question

Stats

  • Questions 389k
  • Answers 389k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer function combineFirstLastName($user) { return $user['first_name'] . ' ' . $user['last_name'];… May 15, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer If you still haven't fixed this, you could try and… May 15, 2026 at 12:44 am
  • Editorial Team
    Editorial Team added an answer preg_match('/\d+/', 'image89.jpg', $matches); $digit = $matches[0]; If you plan to… May 15, 2026 at 12:44 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.