Search:

Type: Posts; User: nesthead98

Search: Search took 0.30 seconds.

  1. Replies
    2
    Views
    395

    [SOLVED] Re: find nonletter characters

    Ah yes, each line contains spaces. Sorry about that. Thanks.
  2. Replies
    2
    Views
    395

    [SOLVED] find nonletter characters

    I have a large document, and I'm looking for each line that contains a non-letter character. Trust that my method of getting each line's string is correct:



    while (hasNextLine()) {
    String...
  3. Re: use of regular expressions in string.replaceAll

    Could you please provide the exact line of code you are thinking? I don't know if those single quotes are to be in the code, or where I'm supposed to use them. Thanks.
  4. use of regular expressions in string.replaceAll

    I have a String in which I'm trying to replace all individual characters (except for spaces) surrounded by spaces with hyphens.
    I thought the code to do this would look something like this:

    str =...
  5. Replies
    11
    Views
    828

    Re: declaring field variables

    I would like it to be a static variable. If I do this:


    public class MyClass {
    private int field;

    public static final MyClass myInstance = new MyClass() {{ field = 3; }};

    }
  6. Replies
    11
    Views
    828

    Re: declaring field variables

    I get this error:

    1 error found:
    File: /.../MyOtherProgram.java [line: 8]
    Error: non-static variable myInstance cannot be referenced from a static context
  7. Replies
    11
    Views
    828

    Re: declaring field variables

    public class MyClass {
    private int field;

    public final MyClass myInstance = new MyClass() {{ field = 3; }};

    }


    public class MyOtherProgram {
  8. Replies
    11
    Views
    828

    Re: declaring field variables

    If I have this as the declaration:


    public final MyClass myInstance = new MyClass() {{ field = value }};

    I get this error:

    File: /.../MyOtherClass.java [line: 128]
    Error: non-static...
  9. Replies
    11
    Views
    828

    Re: declaring field variables

    Alright, I was able to declare the instance, but I wasn't able to edit the fields unless I made the instance non-static. Any solution to that? I'd like to be able to call

    MyClass.myInstance
    ...
  10. Replies
    11
    Views
    828

    declaring field variables

    Hi,
    I would like to declare a static final class instance, and set one of its field variables in the same line (all outside of a method). Ideally, it'd look something like this:



    public class...
Results 1 to 10 of 10