title: Interesting classCastException
body: <p>I have this class:</p>
  
  <pre><code>public class RiddlesHolder extends Application {
  
      String[] funnyRiddles = { "1",
              "1",
              "1",
              "1", };
  
      String[] funnyRiddlesAnswers = { "1", "1", "1", "1",
              "1", };
  
      String[] animalRiddlesList = {
              "2",
              "2",
              "2" };
  
      String[] animalRiddlesAnswersList = { "2", "2", "2" };
  
      public String[] getFunnyRiddles() {
          return funnyRiddles;
      }
  
      public String getFunnyRiddlesByPos(int position) {
          return funnyRiddles[position];
      }
  
      public String[] getFunnyRiddlesAnswers() {
          return funnyRiddlesAnswers;
      }
  
      public String[] getAnimalRiddlesList() {
          return animalRiddlesList;
      }
  
      public String[] getAnimalRiddlesAnswersList() {
          return animalRiddlesAnswersList;
      }
  
  }
  </code></pre>
  
  <p>Now I;m trying to call it inside of an activity and here is how(I'm using a fragment):</p>
  
  <pre><code>public static class PlaceholderFragment extends Fragment {
  
      public PlaceholderFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_funny_riddles,
                  container, false);
  
          final RiddlesHolder riddles = (RiddlesHolder)getActivity().getApplication();
  
          Random rnd = new Random();
  
          int randomRiddle = rnd.nextInt(riddles.getFunnyRiddles().length);
  
          TextView text = (TextView) rootView.findViewById(R.id.txtAnimalRiddle);
          text.setText(riddles.getFunnyRiddlesByPos(randomRiddle));
  
          return rootView;
      }
  }
  </code></pre>
  
  <p>But it throws this exception:</p>
  
  <pre><code>05-03 04:55:21.367: E/AndroidRuntime(1645): FATAL EXCEPTION: main
  05-03 04:55:21.367: E/AndroidRuntime(1645): Process: com.gelasoft.gatanki, PID: 1645
  05-03 04:55:21.367: E/AndroidRuntime(1645): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gelasoft.gatanki/com.gelasoft.gatanki.FunnyRiddles}: java.lang.ClassCastException: android.app.Application cannot be cast to com.gelasoft.tools.RiddlesHolder
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.os.Handler.dispatchMessage(Handler.java:102)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.os.Looper.loop(Looper.java:136)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at java.lang.reflect.Method.invokeNative(Native Method)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at java.lang.reflect.Method.invoke(Method.java:515)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at dalvik.system.NativeStart.main(Native Method)
  05-03 04:55:21.367: E/AndroidRuntime(1645): Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.gelasoft.tools.RiddlesHolder
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at com.gelasoft.gatanki.FunnyRiddles$PlaceholderFragment.onCreateView(FunnyRiddles.java:66)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1500)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:938)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1115)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1478)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.Activity.performStart(Activity.java:5241)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2168)
  05-03 04:55:21.367: E/AndroidRuntime(1645):     ... 11 more
  </code></pre>
  
  <p>What am I missing here? i know that it is something really small, but I can't figure it out, as I'm not so experienced with android.</p>