Wrox Programmer Forums
|
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 23rd, 2006, 07:32 PM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Beginner problem

I try to compile this in 1.4:

StringBuffer[][] data = new StringBuffer[args.length][];

        for(int i = 0; i < args.length; i++)
        {
            data[args.length - i - 1] = new StringBuffer[args[i].length()];
            for(int j = (args[i].length() - 1); j >= 0; j--)
            {
                    data[args.length - i - 1].append(args[i].charAt(j));
            }
        }

I get this error:

C:\¹ola\java\ucenje\Prvi.java:42: cannot resolve symbol
symbol : method append (char)
location: class java.lang.StringBuffer[]
                    data[args.length - i - 1].append(args[i].charAt(j));
                                            ^
1 error


Can somebody help me?
 
Old January 24th, 2006, 05:01 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 198
Thanks: 0
Thanked 0 Times in 0 Posts
Default

data[args.length - i - 1] is a StringBuffer[], not a StringBuffer. You need to add another array index in there in order to turn it to a StringBuffer where you can run the append(String) method.

Jon Emerson
http://www.jonemerson.net/
 
Old January 24th, 2006, 07:33 AM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.
 
Old January 26th, 2006, 10:09 AM
Registered User
 
Join Date: Jan 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have a new problem

why this code compiles but on execution outputs this msg:

Exception in thread "main" java.lang.NoClassDefFoundError: Prvi


Code:
class Nadrazred {
    static String pozdrav() {
        return "Lahko noè";
    }

    String ime() {
        return "Janez";
    }
}



class Podrazred extends Nadrazred {
    static String pozdrav() {
        return "Dober dan";
    }

    String ime() {
        return "Lojze";
    }
}


public class Prvi {
    public static void main(String[] args) {
        Nadrazred p = new Podrazred();
        System.out.println(p.pozdrav() + ", " + p.ime());
    }
}
 
Old February 1st, 2006, 05:27 AM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i tried to run your code and it does not prompt an error.
what is your jdk version? =D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginner to the book with problem Happy Tommy BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 July 9th, 2007 01:09 AM
Problem for a beginner antoneath Beginning PHP 1 January 29th, 2007 09:13 AM
System.Threading timer problem for beginner (Windo erikmail C# 2005 1 June 8th, 2006 08:03 AM
Array beginner problem dboy Java Basics 1 February 9th, 2006 05:51 PM
A vb.net beginner problem kitsam VB.NET 2002/2003 Basics 0 August 23rd, 2004 03:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.