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 8490357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:05:32+00:00 2026-06-10T22:05:32+00:00

Coming from Java Land I have been trying to teach myself Scala. Recently I

  • 0

Coming from Java Land I have been trying to teach myself Scala. Recently I was toying with the Int data type and I decided to look up the API for the Int class here.

What perplexed me was the class definition for Int, which is abstract final.

I am apologetic if I did not read up on the meaning of abstract and final in Scala before asking this question, but I was curious, so I typed out this post right away.

So what I am trying to understand is:
Are the semantics for abstract, final and extends different in Scala?
Again, it is to the best of my understanding that in Java, one cannot have abstract and final at the same time.
So how do I interpret final abstract class Int private extends AnyVal?

  • 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-06-10T22:05:33+00:00Added an answer on June 10, 2026 at 10:05 pm

    As om-nom-nom pointed out in the comment, abstract forbids instantiation (new Int), whereas final forbids subclassing (new Int { ... }).

    The reason for this is that scala.Int is directly represented by the primitive integer type of the Java virtual machine; the other similar types are Byte, Short, Char, Long, Float, Double, Boolean. Because they are primitive types on the runtime (exhibiting better performance than so-called boxed types) and the JVM does not allow to add new primitives, there would be no legal way to extend those types. Also there is no way to instantiate them other than by giving a literal (val i: Int = 33).

    Scala has these types to create a unified object system where there is no logical difference between primitive types and ‘objects’. There is however a hierarchical distinction at the top which is AnyRef (corresponding to java.lang.Object) and AnyVal (corresponding to those primitive types; and adding Scala’s new type Unit).

    More on the unified type system is given by the Tour of Scala: Unified Types

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

Sidebar

Related Questions

I've been toying with c++ for a little while, and coming from java one
Coming from java/groovy/grails we are currently moving to rails. We have been having an
I'm coming from a Java background and trying to port a simple version of
I've recently (4 days) started to learn C++ coming from C / Java background.
I am trying to implement a Queue in C. Coming from Java and other
I just started learning C++(coming from Java & Python) and am trying to learn
As the title says. Coming from Java im used to: private int A; public
i'm coming into C++ from Java/AS3-land, and i'm used to the package-cum-folder structure for
I'm coming from java so this is entirely new to me. I have Visual
I'm learning C++ (coming from java) and recently discovered that you can pass functions

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.