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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:32:13+00:00 2026-06-06T21:32:13+00:00

When I use the scala App trait, I can’t get println to work. This

  • 0

When I use the scala App trait, I can’t get println to work.

This simple example prints as expected,

object HelloWorld {
  def main(args: Array[String]) {
    println("Hello, world!")
  }
}

But once I introduce the trait it does not,

object HelloWorld extends App {
  println("Hello, world!")
}

I get no errors but nothing prints to the console.

  • 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-06T21:32:15+00:00Added an answer on June 6, 2026 at 9:32 pm

    Did you compile it first (running scalac HelloWorld.scala)? See this comment: http://www.scala-lang.org/node/9483#comment-40627

    Edited to add more explanation:
    The first version actually was compiled. Scala files without an explicit main method are run uncompiled as scripts. That means that for your second version, the commands in the file are run sequentially, as though they had been entered into the interpreter–so, the object HelloWorld is created, but no method is called on it. There’s more information about Scala as a scripting language here (scroll to Step 5): http://www.artima.com/scalazine/articles/steps.html

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

Sidebar

Related Questions

I use play2 to create a default scala app: play new test Then: play
Everyone who's done any web application development in Scala knows that you can use
Like in the basic hello world Play! app, you can do: object Application extends
I am writing a Google App Engine web app and wish to use Scala
I'm trying to use a JDO with Google App Engine and Scala. The api
I'm learning Scala and trying to use javax.cache in Scala code and can't find
I use Scala 2.9.1. I have a simple scala interpreter: import scala.tools.nsc.interpreter.IMain import scala.tools.nsc.interpreter.Results.Result
I can launch my app as standalone app (for example from command line) or
I want to use akka in my android app but during conversion I get
I am a bit confused on when to use CC_CONTENT_SCALE_FACTOR() in my app. I

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.