-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package test; | ||
|
||
/** | ||
* Demonstrate different handling of static fields vs class fields. | ||
* @author jbf | ||
*/ | ||
public class StaticFieldClassFieldDemo { | ||
static String warn = "warning"; | ||
static String okay = "ok"; | ||
String status; | ||
StaticFieldClassFieldDemo() { | ||
this.status= warn; | ||
} | ||
void printStatus() { | ||
if ( status.equals(warn) ) { | ||
System.out.println("** "+status+" **"); | ||
} else { | ||
System.out.println(status); | ||
} | ||
} | ||
public static void main( String[] args ) { | ||
new StaticFieldClassFieldDemo().printStatus(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
package test; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* Demo bug seen when converting constructor with map. | ||
* @author jbf | ||
*/ | ||
public class TestMapConstructor { | ||
|
||
Map<String,Integer> fh; | ||
|
||
public TestMapConstructor( String formatString ) { | ||
|
||
this.fh= new HashMap<>(); | ||
|
||
this.fh.put("subsec",0); // converts to fh.put | ||
this.fh.put("hrinterval",0); | ||
|
||
String[] ss = formatString.split("\\$"); | ||
|
||
StringBuilder regex1 = new StringBuilder(100); | ||
regex1.append(ss[0].replaceAll("\\+","\\\\+")); | ||
|
||
} | ||
|
||
public static void main( String[] args ) { | ||
new TestMapConstructor("$Y$m$d.dat"); | ||
} | ||
} |