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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:40:36+00:00 2026-06-14T03:40:36+00:00

In Java, suppose we have a function with the parameter double a . Does

  • 0

In Java, suppose we have a function with the parameter double a. Does it work if I pass an integer as argument? (I mean, is there an implicit conversion?) And in the opposite case: if I have e.g. an integer as parameter, and I pass a double?

Unluckily, I am not able to compile my code at the moment, and I would like to check this assert.
Thank you for your attention.

  • 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-14T03:40:38+00:00Added an answer on June 14, 2026 at 3:40 am

    See JLS – Section # 5.3 for details on Method Invocation Conversion.

    Method invocation contexts allow the use of one of the following:

    - an identity conversion (§5.1.1)
    - a widening primitive conversion (§5.1.2)
    - a widening reference conversion (§5.1.5)
    - a boxing conversion (§5.1.7) optionally followed by widening reference conversion
    - an unboxing conversion (§5.1.8) optionally followed by a widening primitive conversion.
    

    So, your first invocation(int to double) will work fine according to rule # 2.

    But the second invocation(double to int) will give Compiler Error, according to the statement quoted further in the same section: –

    If the type of the expression cannot be converted to the type of the
    parameter by a conversion permitted in a method invocation context,
    then a compile-time error occurs.

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

Sidebar

Related Questions

Suppose I want to use the mergesort algorithm. Does JAVA has a method/function which
Suppose I have a Java Servlet that takes a while to finish computing it's
Suppose you have a Java class hierarchy of about 30 classes, with a base
Suppose I have two Java projects in Maven / Eclipse: An open source application
Suppose I have a Java method that returns a HashMap object. Because a LinkedHashMap
Say suppose I have the following Java code. public class Example { public static
I have two questions about java.awt.Shape . Suppose I have two Shape s, shape1
I'm trying to implement java like url pattern matching in php. Suppose i have
Suppose that I have a 2D array (matrix) in Java like this... int[][] MyMat
Suppose, I have a lot of classes, which are constructed using Java reflection (for

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.