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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:45:43+00:00 2026-05-22T23:45:43+00:00

I am new to Scala and work currently on a project involving both Java

  • 0

I am new to Scala and work currently on a project involving both Java and a Scala modules. Now I’d like to call a Scala method from Java using a parameter of type byte[].

The Scala method has the signature: def foo(data: Array[Byte])

The Java call looks like this: foo(x), where x has the type byte[].

The IDE tells me its not possible:

The method foo(Array) in the type Bar is not applicable for the arguments (byte[])

As an additional constraint it is not preferred to change the Scala method. On the Java side I tried using Byte[], but this didn’t solve the problem. There must exist some conversion?

  • 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-22T23:45:43+00:00Added an answer on May 22, 2026 at 11:45 pm

    As others pointed out, there is no problem in conversion. My IDE is behaving erroneous, and showing imaginary errors which compile without problems. At this moment the call of the receive Method in the main-method in following code is marked with the error:

    The method receive(Array) from the type ScalaByteReceiver refers to the missing type Array

    But this code, which exemplifies my question, compiles fine and yields the expected result:

    Java:

    package stackOverflow;
    
    public class JavaByteSender {    
        public static void main(String... args) {
        new ScalaByteReceiver().receive(new byte[4]);
        }
    }
    

    Scala:

    package stackOverflow
    
    import stackOverflow._
    
    class ScalaByteReceiver{
    
      def receive(bytes: Array[Byte]) {    
        println(bytes.length);
        // prints 4
      }
    }
    

    So Java and Scala understand each other nicely.

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

Sidebar

Related Questions

I'm new to Scala and don't know Java. I want to create a jar
I'm fairly new to Lift/Scala but like the ideas of less code writing and
I am generating the scala AST using the following code: val setting = new
I'm currently testing GAs new async code snippet using two different tracking codes on
Being new to Scala (2.9.1), I have a List[Event] and would like to copy
I am learning Scala and I have a Java project to migrate to Scala.
I'm currently learning scala. Why this code doesn't work: class GenClass[T](var d : T)
I'm new to Scala, I'm using 2.9.1, and I'm trying to get my head
I'm relatively new to scala and made some really simple programs succesfully. However, now
I'm new to Scala, so I may be off base on this, I want

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.