Questions tagged as 'java'

1
answer

Difficulties with rounding using BigDecimal

I wrote the following method: public static double round(double value, int scale) { BigDecimal bd = new BigDecimal(value); bd.setScale(scale, BigDecimal.ROUND_HALF_UP); return bd.doubleValue(); } I make the call: round(72.4697...
asked by 14.10.2014 / 20:21
2
answers

Error when storing data from a Select with Java

Good morning. I would like to know if you have the possibility of storing in a variable the value of a search ( select ). In case I want to store a id of another table with the use of select , however after doing .executeQu...
asked by 25.11.2017 / 14:48
1
answer

Division always resulting in zero

Alpha result is only returning 0. Why? package javaapplication4; public class MediaMovelSuavizaçãoExp { public double CalculoPrevisao(double[] valores){ double[] values = new double[valores.length]; //Calculando o valo...
asked by 04.11.2017 / 18:15
1
answer

Working with Hexadecimal in Java

I saw an example code on the Java documentation site about bit that can be checked here . This class belongs to the example that is quoted in link above: class BitDemo { public static void main(String[] args) { int bitmask =...
asked by 09.06.2017 / 19:24
3
answers

Error in Java - Calculation of the square root

I was doing some basic exercises in Java and one of them asked:    In this example, we will use the sqrt method of the Math class to extract the square root of the number that is typed into a text box, a 'Text field' component f...
asked by 08.06.2017 / 15:52
2
answers

I do not understand why application closes

package com.pedrogouveia.teste1; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.Tex...
asked by 23.06.2017 / 20:30
2
answers

How to validate a wrong digit data?

How could I create an exception in case the user types some invalid option, falls into exception , an error message appears and shows the menu again to the user. I created a flag starting with true , soon after I made a while...
asked by 14.07.2017 / 05:25
2
answers

What is the function of wrap_content?

RelativeLayout onCreateLayout = new RelativeLayout(this); onCreateLayout.setBackgroundColor(Color.CYAN); RelativeLayout.LayoutParams ClickMeParms = new RelativeLayout.LayoutParams ( RelativeLayout.LayoutParams.WRAP_CONTE...
asked by 22.06.2017 / 14:13
1
answer

ExecuteSQL method definition error [closed]

When creating the execute method it generates error at this point rs = stm.executeQuery (sql) what can i do public void excutaSQL(String sql){ try { stm=(Statement) conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,Resul...
asked by 01.02.2017 / 14:10
2
answers

Is it possible to extend in a class via reflection in java?

I work with an API that changes the class name and package name whenever a big update comes out, however, I'm forced to support older versions of the API and for that I use reflections in these cases, I always I have worked with Class.forName...
asked by 16.12.2018 / 01:56