Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- list<Produs> lista = new Produs<>();
- lista.add(new Produs());
- a) lista.stream().filter(p->p.getFirma().equals("Mag")).
- .sorted(Comparator.comparing(Produs::getPret().reversed()).
- .forEach(System.out::println);
- b) lista.stream().map(Produs::getProdus).distinct().forEach();
- c) System.out.println(lista.stream().filter(p->p.getPret())>1000).
- .collcet(Collectors.toList());
- d) lista.stream().collect(Collectors.groupingBy(PRodus::getFirma)).
- .forEach((f,listp)->{ System.out.println(f+""),
- listp.stream().map(Produs::getProdus).
- .forEach(System.out.println);
- })
- class Fir extends Thread{
- private String numeFis;
- private String cuv;
- private nrApar;
- public void run(){
- Scanner fn = new Scanner(new File(numeFis));
- String line;
- while(fn.hasNextLine()){
- line = fn.nextLine();
- = line.split();
- for(String aux:v){
- if(aux.equals(cuv))
- this.nrApr++;}
- init getnrap(){return nrap;}}
- public class Start{
- public static void main(){
- String cuv; Scanner in = new Scanner(System.in);
- cuv = in.nextInt();
- Fir f1 = new Fir("exp1", cuv);
- Fir f2 = new Fir("exp2", cuv);
- f1.start();
- f1.join();
- f2.start();
- f2.join();
- SAU
- public class Myhread extends Thread{
- private String file;
- private HashMap<String, Double>mp;
- public MyThread(){}
- public void run(){
- BufferedReader br = new BufferedReader(new FileReader(this.file));
- String line;
- String [] words;
- while( (line = br.readLine) != 0) {
- words = line.split(",");
- for(String w:words){
- if(mp.containsKey(w[1]))
- mp.put(w[1], Double.parseDouble(w[2])+mpget(w[1]));
- else mp.put(w[1],Double.parseDouble(w[3]));
- }
- public Double getProdValue(String product){return mp.get(prod);}
- IV
- public class Produse extends HTTPServelet {
- Connection con = null;
- public void init() { con = DriverManager.getConnection(URL);}
- public void destroy() {con.close();}
- protected obGet(HTTPServeletRequest request, HTTPServeletResponse response) throws..{
- printWriter fout = res.getWriter();
- fout.println("<html>");
- fout.println("<body>");
- String SQL = "SELECT * FROM Stoc WHERE FIRMA =? AND COD_MAN =?"
- PreparedStatement st = con.prepareStatement(SQL);
- double val = Double.parseDouble(request.getParameter"COD");
- String den = request.getParameter"Nume";
- ResultSet rez = set.ExecuteQuery();
- while(rez.next()){
- fout.println("<h1>"+rez.getString("FIRMA")+rez + "" +
- +rez.getString(2)+...+</h1>");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement