Sign Up

Sign Up to our social questions and Answers to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In
Continue with Google
or use


Have an account? Sign In Now

Sign In

Login to our social questions & Answers to ask questions, answer people’s questions & connect with other people.

Sign Up Here
Continue with Google
or use

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.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Continue with Google
or use

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.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Java

This Category lists all questions related to Java programming language

Share
  • Facebook
5 Followers
11 Answers
40 Questions
Home/Java
  • Recent Questions
  • Answers
  • No Answers
  1. Asked: June 30, 2022In: Java

    How can we set java path in windows 10

    Himanshu kumar
    Himanshu kumar Junior TA @GEEKSFORGEEKS | CONTENT CREATOR | FREELANCE CONTENT WRITER |
    Added an answer on July 17, 2022 at 12:05 am

    Following are the steps for setting the java path in window 10 :- 1- Go to the Search box and type advanced system settings in it. Now click on the View advanced system settings. 2- Select the Advanced tab and then click environment variables. 3- In the system, variables click the New button. Now inRead more

    Following are the steps for setting the java path in window 10 :-

    1- Go to the Search box and type advanced system settings in it. Now click on the View advanced system settings.

    2- Select the Advanced tab and then click environment variables.

    3- In the system, variables click the New button. Now in the edit system variable, type variable name as JAVA_PATH and variable path as the path where the JDK folder is saved and click on OK button Usually the path of the JDK file will be C:\Program Files\Java\jdk1.8.0_60.

    4- Now in the system variables go to the path and click the edit button.

    5- Click the New button.

    6- Now add the following path: %JAVA_HOME%\bin

    I hope this helps.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  2. Asked: June 18, 2022In: Java

    How can I define a global variable in java

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on June 21, 2022 at 12:59 am
    This answer was edited.

    There is no global variable in Java. However, we have a static keyword that we can use to define a global variable by doing something like the below: public class A { public static String var1 = "Oraask"; public static int var2 = 37; } A.var1; A.var2; But be careful because if this class gets unloadRead more

    There is no global variable in Java. However, we have a static keyword that we can use to define a global variable by doing something like the below:

    public class A {
    public static String var1 = "Oraask";
    public static int var2 = 37;
    }
    A.var1;
    
    A.var2;

    But be careful because if this class gets unloaded, you will end up with an undefined null error that is difficult to catch.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  3. Asked: April 26, 2020In: Java

    How to get absolute value in java?

    Hassan AbdElrahman
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on August 11, 2021 at 1:25 am

    Firstly what is absolute value ? it's basically the number value regardless of it's sign so for example if we have a -5 number. So the absolute value of it is 5 without the sign. try below example on any editor to get clear idea : double doubleVar = -130.63; int intVar = 931; double doubleVar2 = 64.Read more

    Firstly what is absolute value ?

    it’s basically the number value regardless of it’s sign so for example if we have a -5 number. So the absolute value of it is 5 without the sign.

    try below example on any editor to get clear idea :

    double doubleVar = -130.63;
    int intVar = 931;
    double doubleVar2 = 64.11;
    System.out.println("absolute value of a: "+Math.abs(doubleVar));
    System.out.println("absolute value of b: "+Math.abs(intVar));
    System.out.println("absolute value of c: "+Math.abs(doubleVar2));

    The output of above example is :

    the absolute value of doubleVar: 130.63
    the absolute value of intVar: 931
    the absolute value of doubleVar2: 64.11

    Best Regards.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  4. Asked: May 5, 2020In: Java

    How to get input in java?

    isouravghosh
    Best Answer
    isouravghosh Junior isouravghosh
    Added an answer on January 26, 2021 at 10:01 pm

    In Java the Scanner class allows the user to take input from the console. It belongs to the java.util package.It is used to read the input of primitive types like int, double, long, short, float, and byte. You can use this example below to understand the way the Scanner class helps to take input froRead more

    In Java the Scanner class allows the user to take input from the console. It belongs to the java.util package.It is used to read the input of primitive types like int, double, long, short, float, and byte.

    You can use this example below to understand the way the Scanner class helps to take input from the user

    import java.util.*;
    class UserInputDemo1
    {
    public static void main(String[] args)
    {
    Scanner sc= new Scanner(System.in); //System.in is a standard input stream
    System.out.print(“Enter your name: “);
    String str= sc.nextLine(); //reads string
    System.out.print(“Your name is : “+str);
    }
    }
    Output :
    Your name is : Sourav //In this case I have taken Input as Sourav so it is printing in the console as Your name is : Sourav

    See less
      • 2
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  5. Asked: November 2, 2019In: Java

    What is the difference between i++ and ++i in Java?

    Gomaa Elmokhtar
    Best Answer
    Gomaa Elmokhtar Explorer
    Added an answer on January 25, 2020 at 7:56 pm

    They both increment  the number with value 1 but but ++i increment the number before the current expression is evaluted, whereas i++ increment the number after the expression is evaluated  for example int i=5; int z=i++; //z equals 5 here int x=++i;  //x equals 6 here  

    They both increment  the number with value 1

    but but ++i increment the number before the current expression is evaluted, whereas i++ increment the number after the expression is evaluated 

    for example

    int i=5;

    int z=i++; //z equals 5 here

    int x=++i;  //x equals 6 here

     

    See less
      • 1
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  6. Asked: August 24, 2019In: Java

    What does this sign operator “+=” do in java?

    Hassan AbdElrahman
    Best Answer
    Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
    Added an answer on October 30, 2019 at 8:30 pm

    Hi @Olivier, it common that z += 5.6 are equivalent to z = z + 5.6, it's one the assignment operators it takes the value of z then add 5.6 to it and at the end store the new result into z ex: double z = 5.5 z += 0.1 // the result of z now is : (5.6) but be careful in java because if "z" is not of tyRead more

    Hi Olivier,

    it common that z += 5.6 are equivalent to z = z + 5.6, it’s one the assignment operators it takes the value of z then add 5.6 to it and at the end store the new result into z

    ex:

    double z = 5.5
    z += 0.1 // the result of z now is : (5.6)

    but be careful in java because if “z” is not of type double you will get an compilation error.

    hope this help.

     

    See less
      • 2
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  7. Asked: May 1, 2017In: Java

    Fatal Error EXCEPTION ACCESS VIOLATION (0xc0000005) when trying to run WEB (PIA) Server

    Googler
    Googler Explorer
    Added an answer on April 13, 2018 at 9:52 pm

    this may be because of java compatibility, so try to delete all the Java files and cleaned the %PATH% and installed it again.

    this may be because of java compatibility, so try to delete all the Java files and cleaned the %PATH% and installed it again.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  8. Asked: March 19, 2017In: Java

    How to create ArrayList from array in Java ?

    Googler
    Googler Explorer
    Added an answer on April 4, 2018 at 9:06 pm

    you can use :[code]List<Integer> intList = new ArrayList<Integer>(Arrays.asList(a));[/code]

    you can use :

    [code]
    List<Integer> intList = new ArrayList<Integer>(Arrays.asList(a));
    [/code]

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  9. Asked: March 27, 2018In: Java

    How to convert milliseconds to mins, seconds in java ?

    Googler
    Googler Explorer
    Added an answer on March 27, 2018 at 10:02 pm

    you can use java.util.concurrent.TimeUnit class Read more [code] String.format("%d mins, %d secs", TimeUnit.MILLISECONDS.toMinutes(milli), TimeUnit.MILLISECONDS.toSeconds(milli) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milli)) ); [/code] If TimeUnit or toMinutes are unsupported (Read more

    you can use java.util.concurrent.TimeUnit class Read more

    [code]
    String.format(“%d mins, %d secs”,
    TimeUnit.MILLISECONDS.toMinutes(milli),
    TimeUnit.MILLISECONDS.toSeconds(milli) –
    TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(milli))
    );
    [/code]

    If TimeUnit or toMinutes are unsupported (such as on Android before API version 9), use the following equations:

    [code]
    int seconds = (int) (milliseconds / 1000) % 60 ;
    int minutes = (int) ((milliseconds / (1000*60)) % 60);
    int hours = (int) ((milliseconds / (1000*60*60)) % 24);
    [/code]

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
  10. Asked: January 6, 2018In: Java

    How to avoid != null statements in java ?

    Googler
    Googler Explorer
    Added an answer on February 28, 2018 at 8:51 pm

    If you use (or planning to use) JetBrains IntelliJ IDEA, a Java IDE, you can use some particular annotations developed by them. Basically, you've got @Nullable and @NotNull. You can use in method and parameters, like this: [code] @NotNull public static String helloWorld() { return "Hello World"; } [Read more

    If you use (or planning to use) JetBrains IntelliJ IDEA, a Java IDE, you can use some particular annotations developed by them.

    Basically, you’ve got @Nullable and @NotNull.

    You can use in method and parameters, like this:

    [code]
    @NotNull public static String helloWorld() {
    return “Hello World”;
    }
    [/code]

    or

    [code]
    @Nullable public static String helloWorld() {
    return “Hello World”;
    }
    [/code]

    The second example won’t compile (in IntelliJ IDEA).

    When you use the first helloWorld() function in another piece of code:

    [code]
    public static void main(String[] args)
    {
    String result = helloWorld();
    if(result != null) {
    System.out.println(result);
    }
    }
    [/code]

    Now the IntelliJ IDEA compiler will tell you that the check is useless, since the helloWorld() function won’t return null, ever.

    Using parameter

    [code]
    void someMethod(@NotNull someParameter) { }
    [/code]

    if you write something like:

    [code]
    someMethod(null);
    [/code]

    This won’t compile.

    Last example using @Nullable

    [code]
    @Nullable iWantToDestroyEverything() { return null; }
    [/code]

    Doing this

    [code]
    iWantToDestroyEverything().something();
    [/code]

    And you can be sure that this won’t happen. 🙂

    It’s a nice way to let the compiler check something more than it usually does and to enforce your contracts to be stronger. Unfortunately, it’s not supported by all the compilers.

    In IntelliJ IDEA 10.5 and on, they added support for any other @Nullable @NotNull implementations.

    See blog post More flexible and configurable @Nullable/@NotNull annotations.

    See less
      • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
1 2

Sidebar

Adv 250x250

Explore

  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials

Footer

Oraask

About

Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

About Us

  • About Us
  • Contact Us

Legal Stuff

  • Privacy Policy
  • Terms & Conditions

Follow

Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

© 2019 Oraask. All Rights Reserved
With Love by Oraask.