mr.oculus Posted April 29, 2008 at 01:39 AM Report Share #182238 Posted April 29, 2008 at 01:39 AM import javax.swing.JOptionPane; public class Main { public static void main(String[] args){ String nome = JOptionPane.showInputDialog("digite seu nome"); String nome1 = JOptionPane.showInputDialog("digite o nome de sua mãe"); if (nome1 = "mr.oculus"){ JOptionPane.showMessageDialog(null,"eu "+nome+" te amo "+nome1); } } } porque não da certo o programa? Link to comment Share on other sites More sharing options...
Betovsky Posted April 29, 2008 at 09:10 AM Report Share #182249 Posted April 29, 2008 at 09:10 AM Epa, já estás registado a quase 1 ano e ainda não sabes o que é o Geshi. "Give a man a fish and he will eat for a day; Teach a man to fish and he will eat for a lifetime. The moral? READ THE MANUAL !" Sign on a computer system consultant's desk Link to comment Share on other sites More sharing options...
Knitter Posted April 29, 2008 at 11:47 AM Report Share #182272 Posted April 29, 2008 at 11:47 AM Por duas razões, primeiro comparação é com dois sinais de igual e não com um e segundo, a comparação de Strings, e outros objectos, é feita com o método equals e não com sinais de igual, que apenas comparam referências e tipos primitivos, assim o teu código teria de passar a: import javax.swing.JOptionPane; public class Main { public static void main(String[] args){ String nome = JOptionPane.showInputDialog("digite seu nome"); String nome1 = JOptionPane.showInputDialog("digite o nome de sua mãe"); if (nome1.equals("mr.oculus")){ JOptionPane.showMessageDialog(null,"eu "+nome+" te amo "+nome1); } } } www.sergiolopes.eu Link to comment Share on other sites More sharing options...
mr.oculus Posted April 30, 2008 at 10:35 PM Author Report Share #182740 Posted April 30, 2008 at 10:35 PM se alguém souber de uma apostila que explique essa parte de java puder me passar pq a q eu tenho é muito resumida Link to comment Share on other sites More sharing options...
zecapistolas Posted May 1, 2008 at 12:40 AM Report Share #182760 Posted May 1, 2008 at 12:40 AM Eu estudei por aki.... 😉 -> http://www.t2ti.com/java_starter.php cumps 😛 Link to comment Share on other sites More sharing options...
MX+ Posted May 5, 2008 at 02:04 AM Report Share #183371 Posted May 5, 2008 at 02:04 AM Em C++ podias comprar strings com "==", porque o C++ te permite definir as acções dos operadores (=, ==, <=, ...) Mas em Java tens sempre de usar métodos. E está explicado. Já agora para começar nada melhor que Thinking in Java. A edição 3 está disponivel gratuitamente no site do autor. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now