• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

class method and strings

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to create a class method that takes a string and returns an array of integers, maybe alphabetical letters and should include upper and lower cases, could anyone give me any ideas, this is my firs java class
[ December 15, 2004: Message edited by: Kenedy Grifin ]
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You might as well bookmark the link to the Java API: Java API

If you look under String, you will find a method that I think you will see could be very helpful to you called toCharArray()

The java API is your friend. When I need to to something that I don't know how to do in java, I usually go to the API and search around to see if I can find something useful there. Nine times out of ten there is a class or method in the API that I can use. This is also a great way to learn. Hope this helps.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this is your first Java class, this question would probably be more appropriate in the Java in General (beginner) forum. Also, you haven't provided enough information for us to help you very much. What exactly does this method do? How does it create the integer array from the String that is passed as a parameter?

Even before you start figuring that out, you should probably work on the syntax for creating a class and declaring a method inside of it. Have you done this much yet? If so, does your code compile? What problems have you encountered? Is there any part of the sytnax you understand?

Hopefully these questions will help you think about what you need to do to write this program. Please come back with specific questions about what you are trying to do. The more information you can provide about your particular problem, the better we can help you figure out a solution to it.

Keep coding!

Layne
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
String str= new String("javaRanch");
int [] strArr = new int[str.length()];
for(int i=0;i<str.length();i++)
strArr[i]=(int)str.charAt(i);


This may help u out
reply
    Bookmark Topic Watch Topic
  • New Topic