Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(Object obiekt : kol){
- System.out.println(obiekt);
- }
- Iterator i = kol.iterator();
- while(i.hasNext()){
- System.out.println(" "+ i.next());
- }
- ArrayList kol = new ArrayList();
- String a;
- a = JOptionPane.showInputDialog("Podaj pierwszy");
- BufferedReader wczyt = new BufferedReader (new InputStreamReader(System.in));
- pom =wczyt.readLine();
- liczba=Integer.parseInt(pom);
- double pom = Double.parseDouble(args[0]);
- args[1].equals("Celsius"))
- char tab[] =s.toCharArray();
- String wczyt;
- wczyt =JOptionPane.showInputDialog("Podaj ilosc marek");
- Integer ile = Integer.parseInt(wczyt);
- String marka = tab[i];
- char org[] =marka.toCharArray();
- Random ii = new Random();
- Integer pom = ii.nextInt(25);
- Arrays.sort(tab);
- public Dvd(String color, String producer, double price) {
- super(producer, price);
- this.color = color;
- }
- abstract public class ElectronicParts extends Product
- public class ElectronicParts extends Product implements ElectronicPartsInterface
- int a = new java.util.Random().nextInt(3);
- switch(a) {
- case 0: throw new Wyjatek1();
- case 1: throw new Wyjatek2();
- case 2: throw new Wyjatek3();
- }
- }
- public static void main(String[] args) {
- try {
- metoda();
- } catch (Wyjatek1 e) {
- System.out.println("Wyjatek nr : 1 ");
- } catch (Wyjatek2 e) {
- System.out.println("Wyjatek nr : 2 ");
- } catch (Wyjatek3 e) {
- System.out.println("Wyjatek nr : 3 ");
- }
- }
- File plik = new File(sciezka);
- FileReader a = null;
- FileWriter b = null;
- try {
- int znak;
- long start=System.currentTimeMillis();
- a = new FileReader("la.txt");
- b= new FileWriter("lb.txt");
- while ((znak = a.read()) != -1){
- b.write(znak);
- }
- long stop=System.currentTimeMillis();
- System.out.println("Czas wykonania (w milisekundach) Readera : "+(stop-start));
- } catch (FileNotFoundException ex) {
- System.out.println("Brak Pliku");
- }
- catch (NumberFormatException e1){
- System.out.println("NumberFormatException");
- //e1.printStackTrace();
- throw e1;
- }
- catch(ArithmeticException e2){
- System.out.println("ArithmeticException");
- // e2.printStackTrace();
- throw e2;
- }
- finally
- {
- //System.out.println("Udalo sie");
- }
- finally {
- a.close();
- b.close();
- }
- FileReader aa = null;
- BufferedReader aaa = null;
- FileWriter bb = null;
- BufferedWriter bbb = null;
- try {
- int znak;
- // TODO code application logic here
- aa = new FileReader("la.txt");
- aaa = new BufferedReader(aa);
- bb= new FileWriter("lbb.txt");
- bbb = new BufferedWriter(bb);
- String line = null;
- long start2=System.currentTimeMillis();
- while( (line = aaa.readLine()) != null){
- bb.write(line);
- }
- long stop2=System.currentTimeMillis();
- System.out.println("Czas wykonania (w milisekundach) BufferedReader : "+(stop2-start2));
- } catch (FileNotFoundException ex) {
- System.out.println("Brak Pliku");
- }
- finally {
- aa.close();
- bb.close();
- aaa.close();
- bbb.close();
- }
- }
- public String toString() {
- return name + telephone;
- }
- Product tab[]=new Product[5];
- tab[0]=new ElectronicParts("SONY",100);
- tab[1]=new ElectronicParts("JVC",50);
- tab[2]= new Dvd("Czarny", "SONY", 250);
- tab[3]=new Dvd("Bialy", "HP", 200);
- tab[4]=new Tv(42,"Philips", 2500);
- void ZglosWyjatek() throws Exception {
- if (new java.util.Random().nextInt(5) == 0)
- throw new Exception();
- }
- }
- int liczba=1;
- Zad3 zad = new Zad3();
- try {
- zad.ZglosWyjatek ();
- liczba++;
- zad.ZglosWyjatek ();
- liczba++;
- zad.ZglosWyjatek ();
- liczba++;
- zad.ZglosWyjatek ();
- liczba++;
- zad.ZglosWyjatek ();
- liczba++;
- } catch (Exception e) {
- System.out.println("Wywołanie nr " + liczba + " ktore wyrzucilo wyjatek");
- }
- FileReader aa = null;
- BufferedReader aaa = null;
- FileWriter bb = null;
- BufferedWriter bbb = null;
- try {
- int znak;
- // TODO code application logic here
- aa = new FileReader("la.txt");
- aaa = new BufferedReader(aa);
- bb= new FileWriter("lbb.txt");
- bbb = new BufferedWriter(bb);
- String line = null;
- long start2=System.currentTimeMillis();
- while( (line = aaa.readLine()) != null){
- bb.write(line);
- }
- long stop2=System.currentTimeMillis();
- System.out.println("Czas wykonania (w milisekundach) BufferedReader : "+(stop2-start2));
- } catch (FileNotFoundException ex) {
- System.out.println("Brak Pliku");
- }
- finally {
- aa.close();
- bb.close();
- aaa.close();
- bbb.close();
- }
- public String toString() {
- return name + telephone;
- HashSet kol = new HashSet();
- ArrayList<Student> kol = new ArrayList<Student>();
- List<klasa> kol = new List<klasa> ()
- public class kom implements Comparator<Student>{
- @Override
- public int compare(Student o1,Student o2){
- double srednia1 =o1.srednia(o1);
- double srednia2=o2.srednia(o2);
- if(srednia1>srednia2){
- return 1;
- }
- if(srednia1<srednia2){
- return -1;
- }
- else
- return 0;
- }
- }
- Collections.sort(kol, new kom());
- System.out.println(kol);
- //serializacja
- ObjectOutputStream out = new ObjectOutputStream(
- new BufferedOutputStream(
- new FileOutputStream(nazwaPliku)));
- out.writeObject(test.getCzas());
- out.close();
- ObjectInputStream in = new ObjectInputStream(
- new BufferedInputStream(
- new FileInputStream(nazwaPliku)));
- b = (dataa) in.readObject();
- // System.out.println(b);
- in.close();
- System.out.println(test);
- public class HelloWorld extends JFrame{
- public HelloWorld(){
- JLabel label= new JLabel("HelloWorld");
- getContentPane().add(label);
- setTitle("HellowWorldSwing");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setVisible(true);
- setSize(300,300);
- }
- BorderLayout border = new BorderLayout(10,10);
- setLayout(border);
- border.addLayoutComponent(label1, BorderLayout.NORTH);
- public class GUI extends JFrame {
- JPanel panel = new JPanel();
- JButton b1 = new JButton("Przycisk");
- int i=0;
- GUI() {
- // setSize(500, 400);
- setTitle("okno");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setContentPane(panel);
- panel.add(b1);
- b1.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- i++;
- b1.setText("Wciśnięto "+i+ " razy");
- }
- }
- );
- pack();
- setVisible(true);
- }
- }
- public class tekstowe extends JFrame {
- JTextField tekst1;
- JTextField tekst2;
- JTextField wynik;
- tekstowe() {
- setTitle("Dodawanie");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- BorderLayout border = new BorderLayout();
- setLayout(border);
- tekst1= new JTextField();
- tekst2= new JTextField();
- wynik= new JTextField();
- JButton plus=new JButton("+");
- getContentPane().add(tekst1);
- getContentPane().add(tekst2);
- getContentPane().add(plus) ;
- getContentPane().add(wynik);
- border.addLayoutComponent(tekst1, BorderLayout.NORTH);
- border.addLayoutComponent(tekst2, BorderLayout.SOUTH);
- border.addLayoutComponent(plus, BorderLayout.WEST);
- border.addLayoutComponent(wynik, BorderLayout.EAST);
- ActionListener sl1=new Dodaj();
- plus.addActionListener(sl1);
- pack();
- setVisible(true);
- }
- class Dodaj implements ActionListener
- {
- public void actionPerformed(ActionEvent zdarzenie)
- {
- long n=Integer.parseInt(tekst1.getText());
- long m=Integer.parseInt(tekst2.getText());
- long suma=n+m;
- wynik.setText(""+suma+" ");
- }
- }}
Add Comment
Please, Sign In to add comment