• Курсы Академии Кодебай, стартующие в мае - июне, от команды The Codeby

    1. Цифровая криминалистика и реагирование на инциденты
    2. ОС Linux (DFIR) Старт: 16 мая
    3. Анализ фишинговых атак Старт: 16 мая Устройства для тестирования на проникновение Старт: 16 мая

    Скидки до 10%

    Полный список ближайших курсов ...

Помогите нубу!

  • Автор темы DarkWay666
  • Дата начала
D

DarkWay666

написал первую прогу

public class MyFirst
{
public static void main (String[] args);
{
System.out.println("It is my first program");
}
}

при копмиляции кидает ошибку

Documents and Settings\DarkWay\Мои документы\JAVA my\my1\MyFirst.java:3: missing method body, or declare abstract
public static void main (String[] args);
^
1 error

Tool completed with exit code 1

как я понял что то неправильно с main но что?
 
D

DarkWay666

public static void main (String[] args); <- убери ;
спс.
А ты сам яву учил или тя учили?
сколько лет ей занимаешься?
сколько может реально получать ява програмер в россии, москве?
 
D

DarkWay666

очередная трабла

import java.io.*;
public class M1
{
public static void main (String[] args)

{
String s;
BufferedReader br = new BufferedReader (new InputStreamReader);
int a;
int b;
int c;
s = br.readLine (s);
a = Integer.parseInt(s);

s = br.readLine (s);
b = Integer.parseInt(s);

s = br.readLine (s);
c = Integer.parseInt(s);

}

}


вот ошибка

'(' or '[' expected
BufferedReader br = new BufferedReader (new InputStreamReader);



ЗЫ этот класс пральна написан import java.io.*;
 

Kmet

Well-known member
25.05.2006
904
8
BIT
0
все же написано

BufferedReader br = new BufferedReader (new InputStreamReader());
 
D

DarkWay666

если так то пишет

cannot find symbol
symbol : constructor InputStreamReader()
location: class java.io.InputStreamReader
BufferedReader br = new BufferedReader (new InputStreamReader());

в new ошибка
 

Kmet

Well-known member
25.05.2006
904
8
BIT
0
потому что у InputStreamReader нет конструктора баз параметров, открой явадок и посмотри какие конструкторы определены.
 
D

DarkWay666

а где взять/открыть ява док, что где читать и что где сматреть? ;)

ЗЫ у меня трабла есть одна незначительная, при запуске консоли в начале идёт строка с (Системе не удаётся найти указанный путь), но всё остальное выводится.
 
D

DarkWay666

а в чём разница между Visual Java и просто Java и где удобнее и перспективнее работать?
 
D

DarkWay666

не могу выполнить задачу :blink:

условие:
нада ввести 2-ух значное число и чтоб из него выводились потом его состовляющие цифры.
например
ввёл 10
и оно должно разложиться на 1 и 0

я написал только ввод но как сделать саму задачу
import java.io.*;
public class DZ1
{

public static void main (String[] args)
throws IOException
{
String s;

BufferedReader br = new BufferedReader (new InputStreamReader(System.in));

s=br.readLine();

System.out.println();

}
}
 
D

DarkWay666

РЕШИЛ!!! :rolleyes:

[codebox]
import java.io.*;
public class DZ1
{

public static void main (String[] args)
throws IOException
{
String s;

BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
int xx;
int nn;
int mm;
int zz;
int cc;
s=br.readLine();

xx=Integer.parseInt(s);

nn=xx/10;
mm=xx%10;
zz=nn/10;
cc=nn%10;


System.out.println (zz);
System.out.println (cc);
System.out.println (mm);

}
}
[/codebox]
 
D

DarkWay666

сделал калькулятор, но есть трабла, когда делаешь вычисления и потом очищаешь и снова пытаешься вычислять, то он начинает писать со второй строки.

вот код:

[codebox]
package one;

import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;
import javax.swing.Box;

public class Frame2 extends JFrame {

long Pr_A=1;
long Pr_Op;

JPanel contentPane;
JButton jButton_First = new JButton();
JButton jButton_Second = new JButton();
JButton jButton_Res = new JButton();
JButton jButton_1 = new JButton();
JButton jButton_2 = new JButton();
JButton jButton_3 = new JButton();
JButton jButton_4 = new JButton();
JButton jButton_5 = new JButton();
JButton jButton_6 = new JButton();
JButton jButton_7 = new JButton();
JButton jButton_8 = new JButton();
JButton jButton_9 = new JButton();
JButton jButton_0 = new JButton();
JButton jButton_Plus = new JButton();
JButton jButton_Minus = new JButton();
JButton jButton_Multiplay = new JButton();
JButton jButton_Del = new JButton();
JButton jButton_Result = new JButton();
JButton jButton_Clear = new JButton();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JLabel jLabel3 = new JLabel();
public Frame2() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}

/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(null);
setSize(new Dimension(400, 300));
setTitle("Calculator");
jButton_First.setBounds(new Rectangle(15, 10, 220, 25));
jButton_First.setHorizontalAlignment(SwingConstants.LEFT);
jButton_First.addActionListener(new Frame2_jButton1_actionAdapter(this));
jButton_Second.setBounds(new Rectangle(15, 40, 220, 25));
jButton_Second.setHorizontalAlignment(SwingConstants.LEFT);
jButton_Second.addActionListener(new
Frame2_jButton_Second_actionAdapter(this));
jButton_Res.setBounds(new Rectangle(15, 70, 220, 25));
jButton_Res.setHorizontalAlignment(SwingConstants.LEFT);
jButton_Res.addActionListener(new Frame2_jButton_Res_actionAdapter(this));
jButton_1.setBackground(UIManager.getColor("Button.background"));
jButton_1.setBounds(new Rectangle(15, 110, 50, 25));
jButton_1.setText("1");
jButton_1.addActionListener(new Frame2_jButton_1_actionAdapter(this));
jButton_2.setBounds(new Rectangle(100, 110, 50, 25));
jButton_2.setText("2");
jButton_2.addActionListener(new Frame2_jButton_2_actionAdapter(this));
jButton_3.setBounds(new Rectangle(185, 110, 50, 25));
jButton_3.setText("3");
jButton_3.addActionListener(new Frame2_jButton_3_actionAdapter(this));
jButton_4.setBounds(new Rectangle(15, 139, 50, 25));
jButton_4.setText("4");
jButton_4.addActionListener(new Frame2_jButton_4_actionAdapter(this));
jButton_5.setBounds(new Rectangle(100, 139, 50, 25));
jButton_5.setText("5");
jButton_5.addActionListener(new Frame2_jButton8_actionAdapter(this));
jButton_6.setBounds(new Rectangle(185, 139, 50, 25));
jButton_6.setText("6");
jButton_6.addActionListener(new Frame2_jButton_6_actionAdapter(this));
jButton_7.setBounds(new Rectangle(15, 170, 50, 25));
jButton_7.setText("7");
jButton_7.addActionListener(new Frame2_jButton_7_actionAdapter(this));
jButton_8.setBounds(new Rectangle(100, 170, 50, 25));
jButton_8.setToolTipText("");
jButton_8.setText("8");
jButton_8.addActionListener(new Frame2_jButton11_actionAdapter(this));
jButton_9.setBounds(new Rectangle(185, 170, 50, 25));
jButton_9.setText("9");
jButton_9.addActionListener(new Frame2_jButton_9_actionAdapter(this));
jButton_0.setBounds(new Rectangle(100, 202, 50, 25));
jButton_0.setText("0");
jButton_0.addActionListener(new Frame2_jButton_0_actionAdapter(this));
jButton_Plus.setBounds(new Rectangle(15, 202, 50, 25));
jButton_Plus.setText("+");
jButton_Plus.addActionListener(new Frame2_jButton_Plus_actionAdapter(this));
jButton_Minus.setBounds(new Rectangle(185, 202, 50, 25));
jButton_Minus.setText("-");
jButton_Minus.addActionListener(new Frame2_jButton_Minus_actionAdapter(this));
jButton_Multiplay.setBounds(new Rectangle(15, 235, 50, 25));
jButton_Multiplay.setText("*");
jButton_Multiplay.addActionListener(new
Frame2_jButton_Multiplay_actionAdapter(this));
jButton_Del.setBounds(new Rectangle(185, 235, 50, 25));
jButton_Del.setText("/");
jButton_Del.addActionListener(new Frame2_jButton_Del_actionAdapter(this));
jButton_Result.setBounds(new Rectangle(100, 235, 50, 25));
jButton_Result.setText("=");
jButton_Result.addActionListener(new
Frame2_jButton_Result_actionAdapter(this));
jButton_Clear.setBounds(new Rectangle(15, 261, 220, 23));
jButton_Clear.setText("Очистить");
jButton_Clear.addActionListener(new Frame2_jButton_Clear_actionAdapter(this));
contentPane.setBackground(UIManager.getColor(
"InternalFrame.inactiveTitleForeground"));
contentPane.setMaximumSize(new Dimension(99999, 20000));
jLabel1.setText("<--- 1-ое значение");
jLabel1.setBounds(new Rectangle(246, 10, 141, 24));
jLabel2.setText("<--- 2-ое значение");
jLabel2.setBounds(new Rectangle(246, 40, 140, 24));
jLabel3.setText("<--- Ответ");
jLabel3.setBounds(new Rectangle(246, 70, 139, 24));
contentPane.add(jButton_First);
contentPane.add(jButton_Second);
contentPane.add(jButton_Res);
contentPane.add(jButton_1);
contentPane.add(jButton_4);
contentPane.add(jButton_7);
contentPane.add(jButton_Plus);
contentPane.add(jButton_Multiplay);
contentPane.add(jButton_Result);
contentPane.add(jButton_0);
contentPane.add(jButton_8);
contentPane.add(jButton_5);
contentPane.add(jButton_2);
contentPane.add(jButton_3);
contentPane.add(jButton_6);
contentPane.add(jButton_9);
contentPane.add(jButton_Minus);
contentPane.add(jButton_Del);
contentPane.add(jButton_Clear);
contentPane.add(jLabel1);
contentPane.add(jLabel2);
contentPane.add(jLabel3);
}

public void jButton8_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"5");
else
jButton_Second.setText(jButton_Second.getText()+"5");
}

public void jButton11_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"8");
else
jButton_Second.setText(jButton_Second.getText()+"8");
}

public void jButton1_actionPerformed(ActionEvent e) {

}

public void jButton_1_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"1");
else
jButton_Second.setText(jButton_Second.getText()+"1");

}

public void jButton_2_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"2");
else
jButton_Second.setText(jButton_Second.getText()+"2");
}

public void jButton_3_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"3");
else
jButton_Second.setText(jButton_Second.getText()+"3");
}

public void jButton_Plus_actionPerformed(ActionEvent e) {
Pr_Op=1;
Pr_A=2;
}

public void jButton_Result_actionPerformed(ActionEvent e) {
if (Pr_Op==1)
{
int a1 = Integer.parseInt(jButton_First.getText());
int a2 = Integer.parseInt(jButton_Second.getText());
int a3=a1+a2;
jButton_Res.setText(Integer.toString(a3));
}
if (Pr_Op==3)
{
int a1 = Integer.parseInt(jButton_First.getText());
int a2 = Integer.parseInt(jButton_Second.getText());
int a3=a1-a2;
jButton_Res.setText(Integer.toString(a3));
}
if (Pr_Op==2)
{
int a1 = Integer.parseInt(jButton_First.getText());
int a2 = Integer.parseInt(jButton_Second.getText());
int a3=a1*a2;
jButton_Res.setText(Integer.toString(a3));
}
if (Pr_Op==4)
{
int a1 = Integer.parseInt(jButton_First.getText());
int a2 = Integer.parseInt(jButton_Second.getText());
int a3=a1/a2;
jButton_Res.setText(Integer.toString(a3));
}

}

public void jButton_4_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"4");
else
jButton_Second.setText(jButton_Second.getText()+"4");
}

public void jButton_6_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"6");
else
jButton_Second.setText(jButton_Second.getText()+"6");
}

public void jButton_7_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"7");
else
jButton_Second.setText(jButton_Second.getText()+"7");
}

public void jButton_9_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"9");
else
jButton_Second.setText(jButton_Second.getText()+"9");
}

public void jButton_0_actionPerformed(ActionEvent e) {
if (Pr_A==1)
jButton_First.setText(jButton_First.getText()+"0");
else
jButton_Second.setText(jButton_Second.getText()+"0");
}

public void jButton_Clear_actionPerformed(ActionEvent e) {


if (Pr_A==1)
jButton_First.setText("");

else
jButton_Second.setText("");

jButton_First.setText("");

jButton_Res.setText("");


if (Pr_A==1)
jButton_Second.setText("");

else
jButton_Second.setText("");

jButton_First.setText("");

jButton_Res.setText("");

}

public void jButton_Minus_actionPerformed(ActionEvent e) {
Pr_Op=3;
Pr_A=2;
}

public void jButton_Multiplay_actionPerformed(ActionEvent e) {
Pr_Op=2;
Pr_A=2;
}

public void jButton_Del_actionPerformed(ActionEvent e) {
Pr_Op=4;
Pr_A=2;
}

public void jButton_Second_actionPerformed(ActionEvent e) {
Pr_A=1;
}

public void jButton_Res_actionPerformed(ActionEvent e) {

}

}


class Frame2_jButton_Res_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Res_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Res_actionPerformed(e);
}
}


class Frame2_jButton_Second_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Second_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Second_actionPerformed(e);
}
}


class Frame2_jButton_Del_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Del_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Del_actionPerformed(e);
}
}


class Frame2_jButton_Multiplay_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Multiplay_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Multiplay_actionPerformed(e);
}
}


class Frame2_jButton_Minus_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Minus_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Minus_actionPerformed(e);
}
}


class Frame2_jButton_0_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_0_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_0_actionPerformed(e);
}
}


class Frame2_jButton_Clear_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Clear_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Clear_actionPerformed(e);
}
}


class Frame2_jButton_9_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_9_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_9_actionPerformed(e);
}
}


class Frame2_jButton_7_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_7_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_7_actionPerformed(e);
}
}


class Frame2_jButton_6_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_6_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_6_actionPerformed(e);
}
}


class Frame2_jButton_Result_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Result_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Result_actionPerformed(e);
}
}


class Frame2_jButton_Plus_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_Plus_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_Plus_actionPerformed(e);
}
}


class Frame2_jButton_3_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_3_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_3_actionPerformed(e);
}
}


class Frame2_jButton_4_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_4_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_4_actionPerformed(e);
}
}


class Frame2_jButton_1_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_1_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_1_actionPerformed(e);
}
}


class Frame2_jButton_2_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton_2_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton_2_actionPerformed(e);
}
}


class Frame2_jButton1_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton1_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}


class Frame2_jButton11_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton11_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton11_actionPerformed(e);
}
}


class Frame2_jButton8_actionAdapter implements ActionListener {
private Frame2 adaptee;
Frame2_jButton8_actionAdapter(Frame2 adaptee) {
this.adaptee = adaptee;
}

public void actionPerformed(ActionEvent e) {
adaptee.jButton8_actionPerformed(e);
}
}
[/codebox]
делал в Borland JBuilder 2006 Enterprise, подскажите где найти норм крэк или ключ для него, а то надоедает каждый раз указывать путь к активационному файлу.
 

Kmet

Well-known member
25.05.2006
904
8
BIT
0
код отправил, а куда заходить и просматривать сообщения?
отправляешь код, получаешь ссылку, ссылку постишь сюда.
ты предлагаешь эклипсом пользоваться?
да
чем он лучше и тд
выбирай из Eclipse, IDEA и NetBeans. все остальное херня
 
D

DarkWay666

есть ИДЕЯ, но там я них**я непонимаю :)
но осилить попробую
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!