Sort by

recency

|

139 Discussions

|

  • + 0 comments

    //** using java 7 static String count(ArrayList mylist){ int a = 0,b = 0,c = 0; for(int i = 0; i < mylist.size(); i++){ Object element=mylist.get(i); if(element instanceof Student) a++; if(element instanceof Rockstar) b++; if(element instanceof Hacker) c++; }

  • + 0 comments

    BeautyPlus’s cloud-based infrastructure means that users can access and edit their photos from multiple devices, whether they are working on a desktop computer, a tablet, or a smartphone. This cross-device functionality not only enhances convenience but also ensures that users can continue their editing projects seamlessly online ai photo editor, no matter where they are. The cloud storage feature also helps in keeping a backup of edited images, reducing the risk of data loss.

  • + 1 comment

    import java.io.; import java.util.;

    public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String[] Name = new String[n];
        for (int i = 0; i < n; i++) {
            Name[i] = sc.next();
        }
        int S_count = 0;
        int R_count = 0;
        int H_count = 0;
        for (int i = 0; i < n; i++) {
            if (Name[i].equals("Student")) {
                S_count++;
            } else if (Name[i].equals("Rockstar")) {
                R_count++;
            } else if (Name[i].equals("Hacker")) {
                H_count++;
            }
        }
        System.out.println(S_count + " " + R_count + " " + H_count);
    }
    

    }

  • + 0 comments

    import java.io.; import java.util.;

    class Student{} class Rockstar{} class Hacker{}

    public class Solution {

    static String count(ArrayList mylist){
        int a = 0,b = 0,c = 0;
        for(int i = 0; i < mylist.size(); i++){
            Object element=mylist.get(i);
            if(element instanceof Student)
                a++;
            if(element instanceof Rockstar)
                b++;
            if(element instanceof Hacker)
                c++;
        }
        String ret = a + " " + b + " " + c;
        return ret;
    }
    
    public static void main(String[] args) {
        ArrayList mylist = new ArrayList();
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        for(int i=0; i<t; i++){
            String s=sc.next();
            if(s.equals("Student")) mylist.add(new Student()); // Added this line
            if(s.equals("Rockstar")) mylist.add(new Rockstar()); // Added this line
            if(s.equals("Hacker")) mylist.add(new Hacker()); // Added this line
        }
        System.out.println(count(mylist));
    }
    

    }

  • + 0 comments

    import java.util.*;

    class Student{} class Rockstar{ } class Hacker{}

    public class InstanceOFTutorial{

    static String count(ArrayList mylist){ int a = 0,b = 0,c = 0; for(int i = 0; i < mylist.size(); i++){ Object element=mylist.get(i); if(element instanceof Student) a++; if(element instanceof Rockstar) b++; if(element instanceof Hacker) c++; } String ret = Integer.toString(a)+" "+ Integer.toString(b)+" "+ Integer.toString(c); return ret; }

    public static void main(String []args){ ArrayList mylist = new ArrayList(); Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0; i