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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:34:52+00:00 2026-05-25T22:34:52+00:00

my env is : Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).

  • 0

my env is :

Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).

watch this example first:

scala> var a = 1
a: Int = 1

scala> var c = 'c
c: Symbol = 'c

scala> var d = 1.1
d: Double = 1.1

scala> var b = "123"
b: java.lang.String = 123

scala> val e:String = "234"
e: String = 234

so, you can see the other literal except string, the default type are Scala Types(Int Double Symbol.

but the string literal is Java type.(java.lang.String

and when you define a value with the scala type String, the String literal will be the type Scala String.

why the string literal’s default type isn’t Scala String?

Second:

when you must call scala method from java.

and your scala method with Parameter like this:

def hello(i:Int) = {
    println(i)
}

on java side . if you call like this.

object.hello(null)

it will fail by type mismatch.

the java.lang.Integer can be null. but the scala Int can’t be null.

null in scala is the subtype of AnyRef. not AnyVal..

i found that AnyRef and AnyVal take me to the java1.4 world, which dose not have autobox.. .

  • 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-25T22:34:53+00:00Added an answer on May 25, 2026 at 10:34 pm

    Answer to your first question:

    scala.String is simply a type synonym defined in Prelude Predef for good old java.lang.String. (Unlike scala.Int, scala.Float etc. which are distinct types from java.lang.Integer, java.lang.Float etc.)

    This might help: (Observe the types.)

    scala> def f(s: String) = s * 2
    f: (s: String)String
    
    scala> f("hello")
    res7: String = hellohello
    
    scala> def f(s: String): java.lang.String = s * 2
    f: (s: String)java.lang.String
    
    scala> f("hello")
    res8: java.lang.String = hellohello
    
    scala> type Str = String
    defined type alias Str
    
    scala> def f(s: String): Str = s * 2
    f: (s: String)Str
    
    scala> f("hello")
    res9: Str = hellohello
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Env: Oracle version: Release 10.2.0.1.0 Server: Windows XP Language in oracle: select userenv('language') from
In my env I require 3.0.3 but when I script/server I get this: can't
Env.: Vista SP1, SQL Server Express 2005 I'm able to connect to my localhost
I'm doing: data = env.InstallAs('$PREFIX/share/odysi', 'data') env.Alias('install', data) Which works fine the first time.
To run a program with custom env settings, we do this on Linux $
Is there a good Flex IDE/development env that works on Ubuntu? Where can this
Env: JBoss 5.1, ehcache 2.1.0, hibernate 3.3.x, seam 2.2.0 ehcache.xml (2.1.0 version) contains the
Env: .NET 1.1 I got into this situation. Where I need to give a
when I do this ip = request.env[REMOTE_ADDR] I get the client's IP address it
Env: Maven 2.2.1 I have two java projects under svn (projectA, projectB). My maven

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.