9 Replies - 389 Views - Last Post: 11 September 2010 - 06:56 PM Rate Topic: -----

#1 xtrabigc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-September 10

private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:10 PM

Hello my name is Chris I have written this code that passes the 4 tests that were asked of me, however I have been stumped for over a day now because I get a yellow line under this:

private static void stringFunction(String ourString)

I'm not sure what I need to do I am a first semester java programmer so any help will be appreciated.
Thank You...



Here is my code:
public class StringWalker 
{  

  public static void main(String[] args)
  {
    String stringy = new String();
    stringy =javax.swing.JOptionPane.showInputDialog(null);
    System.out.println(" [" +stringy +"]");
    int length = stringy.length();
    System.out.println("Total Characters=" +length);
    char c;
    int digits = 0;
    int lower = 0;
    int upper = 0;
    int special = 0;
    for (int i = 0; i < length; i++)
    {
      c = stringy.charAt(i);
      if (c >= '0' && c<='9')
      {
        digits ++;
      }
      if( Character.isLowerCase(c))
      {
        lower ++;
      }
      if( Character.isUpperCase(c))
      {
        upper ++;
      }
      else 
      {
    	special = length - digits - lower - upper;  
      }
     }
    System.out.println("Digits=" +digits);
    System.out.println("Lower-case Letters=" +lower);
    System.out.println("Upper-case Letters=" +upper);
    System.out.println("Special Characters=" +special);
  }
  private static void stringFunction(String ourString)
  {
    System.out.println("now in the method");
    System.out.println(ourString);
  }
}



Is This A Good Question/Topic? 0
  • +

Replies To: private static void stringFunction(String ourString)

#2 tectonic.software  Icon User is offline

  • D.I.C Head

Reputation: 18
  • View blog
  • Posts: 88
  • Joined: 12-February 10

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:14 PM

Please add code tags.

If your programming in Eclipse, Hover over it and it will tell you what it is complaining about. This is not a bad thing most of the time, most of the time it is just a convention thing.

If you not programming in Eclipse, What IDE are you using?
Was This Post Helpful? 0
  • +
  • -

#3 xtrabigc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-September 10

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:17 PM

yes I am using eclipse.
Was This Post Helpful? 0
  • +
  • -

#4 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 9044
  • View blog
  • Posts: 33,551
  • Joined: 27-December 08

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:19 PM

What is the warning it is giving you?
Was This Post Helpful? 0
  • +
  • -

#5 xtrabigc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-September 10

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:23 PM

The method stringFunction(String) from the type StringWalker is never used locally
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 9044
  • View blog
  • Posts: 33,551
  • Joined: 27-December 08

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:25 PM

You don't invoke the method in the project is what the yellow is telling you. One thing with IDEs is that they have a lot of prompting for these types of trivial warnings. This one you can safely ignore.
Was This Post Helpful? 0
  • +
  • -

#7 xtrabigc  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 11-September 10

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:28 PM

View Postmacosxnerd101, on 11 September 2010 - 05:25 PM, said:

You don't invoke the method in the project is what the yellow is telling you. One thing with IDEs is that they have a lot of prompting for these types of trivial warnings. This one you can safely ignore.


thank you so if I submit this assignment would I not have to worry about losing any points for this warning?
Was This Post Helpful? 0
  • +
  • -

#8 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 9044
  • View blog
  • Posts: 33,551
  • Joined: 27-December 08

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:31 PM

You won't lose any points over syntax errors. I can't speak as to whether or not it is in the parameters of the assignment.
Was This Post Helpful? 0
  • +
  • -

#9 davidobryen  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 26
  • Joined: 11-September 10

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:33 PM

If the program satisfies all of the criteria you mentioned, then you could probably safely remove the unused procedure. It's up to you to decide.
Was This Post Helpful? 0
  • +
  • -

#10 cfoley  Icon User is offline

  • Cabbage
  • member icon

Reputation: 1508
  • View blog
  • Posts: 3,219
  • Joined: 11-December 07

Re: private static void stringFunction(String ourString)

Posted 11 September 2010 - 06:56 PM

The warning is telling you something important. You can ignore it safely but a fix is quick and easy too.

The method is never called, and leaving dead code around is a bad idea.

If it's never supposed to be called then you should delete it.
If it is supposed to be called you should find out what happened to the code that calls it.
If it's supposed to be available to other classes it should be made non-private.

Only one of these will be correct. I'd be very suspicious of the latter, especially if other classes are not giving errors when they can't find it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1