The Artima Developer Community
Sponsored Link

Java Answers Forum
i include string.

1 reply on 1 page. Most recent reply: Oct 7, 2002 11:16 PM by Singh M.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Cshah

Posts: 16
Nickname: tkc204
Registered: Oct, 2002

i include string. Posted: Oct 7, 2002 10:33 PM
Reply to this message Reply
Advertisement
this is wat my code looks like:

import javax.swing.*;

public class hwk3
{
public static void main( String[] args )
{

String name;
name = JOptionPane.showInputDialog( "Enter one word" );
int numChar=name.length();

// print letter

System.out.println( "The number of Characters is: " + numChar + "," );
isHyphenated(name);


System.exit( 0 );

}

public static void isHyphenated(String word)
{
int index=0;
while( index < word.length())
{

if(charAt(index) == '-')

System.out.println("There is a hyphen at position:" + index);

index = index + 1;
}

}


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: i include string. Posted: Oct 7, 2002 11:16 PM
Reply to this message Reply
Replace if(charAt(index) == '-')
with if(word.charAt(index) == '-')

Flat View: This topic has 1 reply on 1 page
Topic: can any one answer me to these questions??? Previous Topic   Next Topic Topic: movies database help .. please

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use