Search code examples
javastringnetbeansstringbuffer

String buffer help needed


I did exactly what has been instructed in this tutorial(https://www.youtube.com/watch?v=hyVmCqiCNmY) of stringbuffer, but I am getting an error in Netbeans with an orange line right across this line of code

StringBuffer b = New StingBuffer("how are you doing today");

whereas when Iam doing the same thing in eclipse, there is no such error

Program:

public class StringBuff {

    public static void main(String[] args) {
        StringBuffer b = New StingBuffer("how are you doing today");

        System.out.println(b);
    }

}

I tried to add the image of the program from Netbeans, but I don't qualify yet to add images.


Solution

  • It seems that you have typo in New. Java is case sensitive so New is different than new.

    BTW StringBuffer is supplemented by StringBuilder. The orange line does not indicate an error but code that should be improved.

    This class is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread (as is generally the case). Where possible, it is recommended that this class be used in preference to StringBuffer as it will be faster under most implementations.

    Read the official Java Tutorial, not some YT video.