regex - Java scoping issue -
Can anyone see my code and try to help me figure it out? This is a regex app that parses user commandline questions.
Public class interrupt commmissions {public static zero major (string [] args) {string A; Command c = new command (); Java.util.Scanner Reader = New Scanner (System.in); System.out.println ("Enter command:"); A = Reader NXtine (); // Scanning string user input string line = a; // command command string pattern 1 = "(? Lt; =) - ([o] \\ s). Filter order string pattern 2 =" (? & Lt; = (-) ([ F] \\ s). // Create Pattern Object Patterns r1 = Pattern.compile (pattern1); Pattern r2 = Pattern.compile (pattern2); // Creating Matter Objects Mater M1 = R 1. Matter (A) ; Matcher M2 = R 2. Mattere (A); // If order match (m1.find ()) {string s1 = m1.group (0); println (s1); ** it works ** System.out.println (c.returnActions1 (s1)); ** says that the print is not applicable for debate **} and if (m2.find ()) Writing s2 = m2.group (0); println (s2); ** This works ** System.out.println (c.returnActions2 (s2)); ** says that print is not applicable for arguments * *} And {System.out.println ("no matching for given input");}} public class command {string A; public zero return verb 1 (string s1) {string [] command = s1.split ( ","); (Int i = 0; i & lt; commands.length; i ++) {if (commands [i] .equals ("TITLE")) {// select "TITLE" & lt ; Dataframe & gt; } And if (commands [i] .equals ("DATE")) {// Select "DATE" from & lt; Dataframe & gt; }}} Public zero return action 2 (string s2) {string [] command = s2.split (","); For (int i = 0; i & lt; commands.lampper; i ++) {if (commands [i] amends ("TITLE")) {// ORDER & lt; Dataframe & gt; "TITLE") and if (commands [i] .equals ("DATE")) {// ORDER & lt; Dataframe & gt; "DATE" by}}}}} Any thoughts on what's wrong? I'm sure Im has failed to accurately scope my variables, or maybe they should normally get instant. The problem arises when I pass my main variables to other class methods in the main.
assuming that you really want the command to be an internal class:
command c = new command (); Fails to compile with an error
Error: non-static variable can not be referenced from a static reference command static will have to take care of this problem. Then,
System.out.println (c.returnActions1 (s1)); fails to compile with error
Error: 'zero' type is not allowed here Which is a logical
the result of definition of return as a public zero return action 1 (string s1) {/ code> As I do not know In fact, what you want to do in that method, I can only suggest changing its return type
public string return No Action 1 (string S1) { and to return the return return statement to that method.
Comments
Post a Comment