Skip to content

Commit

Permalink
#6 add demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jbfaden committed Oct 16, 2022
1 parent f102afc commit 2890b48
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/java/test/StaticFieldClassFieldDemo.java
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();
}
}
32 changes: 32 additions & 0 deletions src/java/test/TestMapConstructor.java
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");
}
}

0 comments on commit 2890b48

Please sign in to comment.