Trying to write a code that makes a string become altcase (ie. "hello" becomes "HeLlO". I borrowed code from another question on this forum that asked for something similar ([Java Case Switcher](https://stackoverflow.com/questions/34029652/java-case-switcher)) However, the code only switched the casing of a letter instead of having a capital letter (first), then lowercase letter, etc. pattern.

What I have so far:

```
public String altCase(String text)
{
      String str = "";
      for (int i = 0; i <= text.length(); i++)
       {
        char cA = text.charAt(i);

        if (text.charAt(0).isUppercase)
        {
            str += Character.toLowerCase(cA);
        }

        if (text.charAt(0).isLowercase)
        {
            str += Character.toUpperCase;
        }

        if(i != 0 && Character.isUpperCase(cA))
        {
          if (text.charAt(i)-1.isUpperCase || text.charAt(i)+1.isUpperCase)
          {
              str += Character.toLowerCase(cA);
          }

          else
          {
              str += cA;
          }
        }

    if(i != 0 && Character.isLowerCase(cA))
        {
            if (text.charAt(i)-1.isLowerCase || text.charAt(i)+1.isLowerCase)
            {
            str += Character.toUpperCase(cA);
            }

            else
            {
                str += cA;
            }
        }
   }
      return str;
 }

```

I'm still relatively new to coding in general so please excuse my inefficiencies, as well as any headaches I might induce from the lack of experience in my coding. I cannot tell where I am going wrong except maybe when I typed "text.charAt(i)-1.isLowerCase" as the statement seems a bit illogical, but I am lost in terms of trying to come up with something else that would accomplish the same thing. Or is my error completely elsewhere? Thanks for any help in advance.