Sort by

recency

|

153 Discussions

|

  • + 0 comments

    Use this code This works perfectly 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

    This problem helps you understand runtime type checking in Java.

    No need to use .getClass() or generics — just use instanceof.

  • + 0 comments

    Here is Java InstanceOf Keyword solution - https://programmingoneonone.com/hackerrank-java-instanceof-keyword-problem-solution.html

  • + 0 comments

    Through targeted acquisitions, the company is able to bring fragmented healthcare providers under a unified framework Get details here, creating economies of scale and enabling better integration of services. This approach not only increases access to healthcare in underserved regions but also enhances the overall quality and consistency of care by implementing standardized practices and shared technologies across acquired entities.

  • + 0 comments

    This test is broken for Java 15. It will not read in from STDIN. Java 7 and 8 read STDIN and seem to work properly. I had issues with latest Firefox. Java 7 and Java 8 seem to run better on Chrome.

  • + 0 comments

    On Java 15, I get

    ~ no response on stdout ~

    from the code below. Am I missing something?

    public class Solution {
    
        public static void main(String[] args) {
            System.out.println("FOO");
        }
    }