Questions tagged as 'java'

1
answer

How to traverse a binary tree?

I'm having difficulty adding an element to a binary tree because I do not know how to go through it ... Tree node public class NodeBinaryTree extends BinaryTree{ NodeBinaryTree left; NodeBinaryTree right; int elemento; publ...
asked by 01.06.2014 / 16:46
1
answer

Compare prices taking into consideration units (kg, g)

Hello, I need to compare 2 products, taking into account their weight and values, to know which product is most advantageous to buy. Ex: Rice 5kg - $ 10.00 Rice 2kg - $ 6.00 Thinking you can compare grams with kg by doing the right convers...
asked by 10.06.2014 / 02:22
2
answers

Attach TXT file using Javamail

I'm using Javamail to send email, with attachment, on Android. When attaching a file with a ".txt" extension, it is assigning the content to the email body, not as an attached file. My code for file attachments: public void addAttachment...
asked by 23.07.2014 / 19:43
3
answers

Doubt in Arrays - Beginner

How do I get the mostraEmpregados method to print the name of the employees I've already added? How to construct the array within the Enterprise class declaration itself, so that every time a Empresa is instantiated, the array o...
asked by 17.08.2014 / 04:11
2
answers

Recursion: Calculate the sum of the first odd odd values starting at 5

I'm doing some exercises on and I stopped in that a few days ago. I came up with the following code: /** * Funcao: Soma dos primeiros valores ímpares positivos começando em 5. * @param quantidade - quantidade de valores a somar...
asked by 20.09.2018 / 02:57
2
answers

How to use the Primefaces p?

Set the nome field by using p:inputText to receive values, it is a field . How do I display a message showing that this field is required, using p:messages ? I'm also using JSF. Follow my HTML: <h:form> &l...
asked by 11.11.2015 / 20:16
1
answer

Analysis and correction of connection test errors using DB using hibernate

Class to test bank connection with hibernate. package br.drogaria.main; public class HibernatUtilTeste { public static void main(String[] args) { //abre sessão HibernateUtil.getFabricaDeSessao().openSession(); /...
asked by 09.10.2015 / 13:40
1
answer

How to create a timer in JAVA?

I'd like to determine how long an image should stay until it comes back to the other. Is there any class for this? Otherwise, how to create? Note: Preferred is the absence of Threads.     
asked by 06.11.2015 / 00:35
1
answer

Calculator - operations with decimals

Once again I appear with this calculator here, I've been much helped with it and it's almost done! All operations are working perfectly, with no error, except for a small detail ... it can only do calculations like 9+8 , 7*8 , etc...
asked by 11.04.2014 / 06:47
1
answer

Java design pattern for code reuse

I'm developing a simple program in Java Desktop using SqLite to store local data, I would like to know which design pattern I can use to reuse Java to develop the same application for Android in my project I'm using t...
asked by 01.04.2014 / 22:12