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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:05:18+00:00 2026-06-02T02:05:18+00:00

Again problem with understanding Java. When I asked previous question about Hello world in

  • 0

Again problem with understanding Java. When I asked previous question about Hello world in Java versus python, I received suggestion of taking the language as granted for a while till I don’t get hang of it. However, I cannot take that approach and is baffled by some weird things in Java versus python.

Here is the program which takes input from user and convert F to degree Celsius in python.

def main ():
 fahr = input (" Enter the temperature in F: ")
 cel = ( fahr - 32) * 5.0/9.0
 print " the temperature in C is : " , cel

This is pretty straightforward without any quirky things going on inside.

The example to do the same thing in Java:

import java . util . Scanner ;

 public class TempConv {
 public static void main ( String [] args ) {
 Double fahr ;
 Double cel ;
 Scanner in ;

 in = new Scanner ( System . in );
 System . out . println (" Enter the temperature in F: " );
 fahr = in . nextDouble ();

 cel = ( fahr - 32) * 5.0/9.0;
 System . out . println (" The temperature in C is : " + cel );

 System . exit (0);
 }

 }

What I thought should happen was: Scanner was Java class/instance of class/object to take user input and with

Scanner in

created a new object to take user input. It turns out to be we are just declaring in to be of Scanner type in Java (Correct me if I am wrong).

Now, if it was python, we would have just called the method of the newly created Scanner object that takes input from the user. OMG, what is this in Java? We create

new Scanner

object and pass System.in as a parameter and assign it to

in

again?

Can somebody please explain to me in pythonic terms, What is happening here and how and why it should differ from python so much?

Any creative suggestions are appreciated.

  • 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-02T02:05:20+00:00Added an answer on June 2, 2026 at 2:05 am

    Your question is a little garbled, but here’s my attempt at an answer. In Java, just like in Python, you need to instantiate a class before you can call methods on it. In Python, you might do this:

    myvar = MyClass(name="example")
    

    In Java, the syntax is very similar:

    in = new Scanner(System.in);
    

    And just like in Python, we can now call methods on it, such as:

    fahr = in.nextDouble();
    

    This is just about identical to what the equivalent Python code would look like. It’s possible I’m not understanding the source of your confusion, so if this doesn’t help let me know and I’m happy to update things.

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

Sidebar

Related Questions

Hello I've runned in to a problem again that I can't solve on my
Ok this question is more about understanding what the issues are as I dont
I'm deleting a previously asked question and asking again more succinctly now that I
I have this problem again and again... and still have not a satisfactory answer...
I'm facing this problem again and again, but can't find any solution (except mine,
I see this problem on and off again in my PHP coding, and I've
its me again with this project. im having a problem reading the text on
I've looked at this over and over again and I can't see the problem.
9 months later, the same problem shows up again. I've tried everything I can
i have againg a problem with completition. now i can't get any suggestion. Sure

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.