Questions tagged as 'java-8'

1
answer

How to access the value of a private attribute in a class in Java without a public method?

How can I access the value of a private attribute in a class, from a class in another package, without using an access method, such as a getter? class Person{ private String name = "Someone"; } Why would anyone do this? One of the r...
asked by 27.06.2015 / 15:04
1
answer

Printing a sequence of 3-by-3 formatted numbers separated by dashes

Let's say I have the following String S = "00-44 48 5555 8361" entry and I need to return this 3-by-3 split string separated by "-" as follows:    Output: 004-448-555-583-61 The number of characters may vary. Below the following sc...
asked by 17.10.2018 / 04:26
1
answer

Distance between two points

Read the four values corresponding to the axes x and y of any two points in the plane p1(x1,y1) and p2(x2,y2) and calculate the distance between them, showing 4 decimal places after the comma, according to the formula...
asked by 28.06.2018 / 01:12
1
answer

Save text with line breaks in the DB

See below a java code to save a SQL command return in PostgreSQL. The command is EXPLAIN ANALYZE. The problem is that by saving this to the database, it loses the line breaks. Someone would know how to help me solve this, that is, so that when d...
asked by 16.01.2018 / 03:50
1
answer

Error generating a JSON object

I'm trying to create this object: { "schema": [ "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:core:2.0:User" ], "endereco": "Rua 0"...
asked by 21.11.2017 / 17:15
2
answers

Transform a for in lambda with variable interaction

How do I transform the following into a Lambda code? The idea is to multiply maxScore by i so that with each interaction it raises the number, only for the first 5 results. for(int i=0;i<5;i++){ list.get(i).se...
asked by 04.08.2017 / 15:17
2
answers

Generic DAO with CDI error = can not be cast to java.lang.reflect.ParameterizedType

I'm trying to implement a generic DAO with CDI. Apparently I'm doing it right, however I'm getting the following error:    can not be cast to java.lang.reflect.ParameterizedType This error is pointing me to this line of my Repository clas...
asked by 28.06.2017 / 17:44
2
answers

TomCat does not activate Spring boot. How do you activate it?

I'm doing a project using Spring boot in IntelliJ + maven. Following and reading tutorials. I did the step by step but when giving Run the Tom Cat is not demonstrated, activated. I am not using any other server. Below is the code Main + Pom + Co...
asked by 13.04.2017 / 00:50
1
answer

Why is my String names accepting integers instead of letters?

import java.util.Scanner; public class Tp1 { public static void main (String [] args){ final int qtdAlunos = 5; String [] nomes = new String[qtdAlunos]; double[] av1 = new double[qtdAlunos]; double[] av2 = new double[qt...
asked by 08.11.2016 / 20:14
1
answer

Java does not compile .java [closed]

Java does not compile return error can not find nor load main class com.sun.tools.javac.Main.     
asked by 02.07.2016 / 17:21