Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #31363

unable to understand some code

Newsgroups comp.lang.java.programmer
Date 2015-03-24 23:56 -0700
Message-ID <5a671b9c-fd76-46bd-92f7-0480c162c5dd@googlegroups.com> (permalink)
Subject unable to understand some code
From Vish <vishal.kaushish@gmail.com>

Show all headers | View raw


public class Test
{
    private final static Class<?>[] TEST_CLASSES = new Class[]{};
    private static final String DEFAULT_OS = "window";
    private static final String DEFAULT_BROWSER = "firefox";

    public static void main(String[] args)
    {
        if (args.length > 0) {
            for (int i = 0; i < args.length && args[i].split("=").length == 2; i++) {
                String key = args[i].split("=")[0];
                String value = args[i].split("=")[1];
                System.setProperty(key, value);
            }
        }
       
        System.out.println("window: " + System.getProperty("window", DEFAULT_OS));
       

        List<String> testSuites = new ArrayList<String>();
		
		----
		some other code
		----
	}
	
	I am not able to understand below things from above code, Please help me to understand the below 	
	
	1. Mentioned inside the for loop, (i < args.length && args[i].split("=").length == 2), what does mean "args[i].split("=").length == 2"
  
	2. String key = args[i].split("=")[0];
       String value = args[i].split("=")[1];
in 2nd point seems like array 1st and 2nd index for [0] and [1] but confusing 
	   
	  What does mean args[i].split("=")[0]; and args[i].split("=")[1]; I am confused with [0] and [1] written in the end
	  
	  

Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

unable to understand some code Vish <vishal.kaushish@gmail.com> - 2015-03-24 23:56 -0700
  Re: unable to understand some code Jeff Higgins <jeff@invalid.invalid> - 2015-03-25 08:11 -0400

csiph-web