Hey there,
I need some help with the subject of searching a string. I have a piece of code which im confused as to why it doesnt work. Sorry if it turns out to be a simple mistake but I'm not familiar with this area of coding. This code is meant to search the string and find the 3rd number in it. Cheers in advance
The code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.awt.Color; /** * Write a description of class Chicken here. * * @author (your name) * @version (a version number or a date) */ public class Chicken extends Actor { /** * Act - do whatever the Chicken wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { GreenfootImage hiho = new GreenfootImage ( "I am Greg" , 50 , Color.BLACK, Color.WHITE); setImage(hiho); System.out.println(hiho.charAt( 3 )); } } |