Ah yes, each line contains spaces. Sorry about that. Thanks.
Type: Posts; User: nesthead98
Ah yes, each line contains spaces. Sorry about that. Thanks.
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...
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.
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 =...
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; }};
}
I get this error:
1 error found:
File: /.../MyOtherProgram.java [line: 8]
Error: non-static variable myInstance cannot be referenced from a static context
public class MyClass {
private int field;
public final MyClass myInstance = new MyClass() {{ field = 3; }};
}
public class MyOtherProgram {
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...
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
...
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...