170 Answered Questions for the topic Java

03/15/19

need help with this javascript code

Create an array that stores the names of five dogs.Using a loop, evaluate an array index for even numbers. If the value is even, then output "dog name is a good dog", and if it is an odd number,... more

03/14/19

How to create a method to return 1 or 0 without using conditions?

I was asked a question in an interview to return 1 if provided 0 and return 0 if provided 1 without using conditions i.e if, ternary etc Just to give you and idea below code without if's: public... more

03/14/19

What is the difference between == and equals() in Java?

I wanted to clarify if I understand this correctly: - `==` -> is a reference comparison, i.e. both objects point to the same memory location - `.equals()` -> evaluates to the comparison of... more

03/14/19

Ignoring new fields on JSON objects using Jackson?

I'm using Jackson JSON library to convert some JSON objects to POJO classes on an android application. The problem is, the JSON objects might change and have new fields added while the application... more

03/14/19

How to get the last value of an ArrayList?

How can I get the last value of an ArrayList? I don't know the last index of the ArrayList.

03/14/19

Hashset vs Treeset?

I've always loved trees, that nice `O(n*log(n))` and the tidiness of them. However, every software engineer I've ever known has asked me pointedly why I would use a `TreeSet`. From a CS background,... more

03/14/19

Can an abstract class have a constructor?

Can an abstract class have a constructor? If so, how can it be used and for what purposes?

03/14/19

How to set or change the default Java (JDK) version on OS X?

How can you change the default version of Java on a mac?

03/14/19

Why are you not able to declare a class as static in Java?

Why are you not able to declare a class as static in Java?

03/13/19

How do I programmatically determine operating system in Java?

I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different properties based on whether I am... more

03/13/19

Is JavaScript front end or backend?

03/13/19

String.equals versus ==?

This code separates a string into tokens and stores them in an array of strings, and then compares a variable with the first home ... why isn't it working? public static void... more

03/13/19

Is PHP front end or back end?

03/13/19

Java: convert List<String> to a String?

JavaScript has `Array.join()` js>["Bill","Bob","Steve"].join(" and ") Bill and Bob and Steve Does Java have anything like this?

03/12/19

What is front end and back end web development?

02/24/19

Drawing a half arrow (Java)

Is anyone able and willing to help me? Here is the task:This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by user... more

01/25/19

What does 'static' mean in Java?

11/23/18

covert algorithm to code java

INPUT initial approximation p0; tolerance TOL; maximum number of iterations N0.OUTPUT approximate solution p or message of failure.Step 1 Set i = 1.Step 2 While i ≤ N0 do Steps 3–6.Step 3 Set p =... more

11/22/18

Howto create a java program that uses both observer design pattern and strategy design pattern?

Use the Java Observable /Observer classes to create an Observable object that provides "real - time" election statistics. For the purposes of this assignment you can just report on any five states... more

09/13/18

Every variable in java must be declared before it is used

Informatics, I'm trying to find true or false answers 

04/03/18

What is wrong in this program ?

import java.util.*;class Twin{ int n=0; int c=0; int Is_Prime(int a) { for(int i=1;i<=a;i++) { if(a%i==0) c=c+1; } if(c==2) return 1; else { return 2; } } } public class Twin_prime{ public... more

02/15/18

How many calls to mystery are made (including the first call) of mystery(0, 4, 5) when arr = {1, 2, 3, 5, 7}?

Give the following code:private int[] arr;public int mystery(int low, int high, int num) { int mid = (low+high) / 2; if (low > high) { return -1; } else if (arr[mid] < num) { return... more

08/08/17

Create a java program that will asks the user's height in centimeters and display the equivalent feet and inches.

Create a java program that will asks the user's height in centimeters and display the equivalent feet and inches. Possible output should be.   Please enter your height(cms):_________ Your... more

07/20/17

Something is wrong with my program. It keeps saying that 4 lines of code are wrong.

Can anyone help me?     The 4 lines of code that are wrong: import java.awt.Dimension;import java.awt.Graphics;import java.awt.Color;import javax.swing.*;           The code: package... more

07/19/17

Homework problem is in the description

Prepare a program that will perform the followings:1) It will prepare a drawing area of 600 pixels by 600 pixels.2) It will draw (not fill) a black rectangle with the following 4 corners: (100,... more

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.