Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 716653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T05:19:25+00:00 2026-05-14T05:19:25+00:00

Related question, about assignment-initialization-declaration. $ javac MatchTest.java MatchTest.java:7: ‘)’ expected for((int i=-1 && String

  • 0

Related question, about assignment-initialization-declaration.

$ javac MatchTest.java 
MatchTest.java:7: ')' expected
  for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
          ^
MatchTest.java:7: ';' expected
  for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
                         ^
MatchTest.java:7: ';' expected
  for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
                                       ^
MatchTest.java:7: not a statement
  for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
                                          ^
MatchTest.java:7: illegal start of expression
  for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
                                                                    ^
5 errors
$ cat MatchTest.java 
import java.util.*;
import java.io.*;

public class MatchTest {
 public static void main(String[] args){
  String text = "hello0123456789hello0123456789hello1234567890hello3423243423232";
  for((int i=-1 && String match="hello"); (i=text.indexOf(match)+1);)
   System.out.println(i);
 }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T05:19:25+00:00Added an answer on May 14, 2026 at 5:19 am

    You can’t declare and initialize a variable of a second type, but you can have multiple variables (possibly with initialization) of the same type.

    This is a common idiom of caching a for bound in a local variable:

    String s = "Hello";
    for (int i = 0, L = s.length(); i < L; i++) {
        System.out.println(s.charAt(i));
    } // prints "H", "e", "l", "l", "o"
    

    This is a common idiom for mapping a 1D-2D array:

    int[] arr1d = new int[9];
    int[][] arr2d = {
        { 1, 2, 3 },
        { 4, 5, 6 },
        { 7, 8, 9 },
    };
    for (int r = 0, i = 0; r < 3; r++) {
        for (int c = 0; c < 3; c++) {
            arr1d[i++] = arr2d[r][c];
        }
    }
    System.out.println(Arrays.toString(arr1d));
    // prints "[1, 2, 3, 4, 5, 6, 7, 8, 9]"
    

    This idiom of two iterators coming in from both ends is also common:

    boolean isPalindrome(String s) {
        for (int i = 0, j = s.length() - 1; i < j; i++, j--) {
            if (s.charAt(i) != s.charAt(j)) {
                return false;
            }
        }
        return true;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 492k
  • Answers 492k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Personally I use this Ajax upload http://valums.com/ajax-upload/ and I'm satisfied… May 16, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer Yep! Update Following the advice of everyone, I updated the… May 16, 2026 at 10:29 am
  • Editorial Team
    Editorial Team added an answer Google Maps relies on lots of small, tiled images, as… May 16, 2026 at 10:29 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

We've gotten a homework assignment in Java, which relates to inheritance. I don't have
I want to ask a question about the iPhone application. I am going to
I read about Session Hijacking articles and would like to some more information related
I have a question and I'm not sure about the best way to design
In other MVP-related questions on SO, people talk about the Presenter keeping the state
Related Questions : Benefits of using short-circuit evaluation , Why would a language NOT
I am taking a CS class, and most of the assignments were in java.
I understand that memberwise assignment of arrays is not supported, such that the following
I'm getting the (probably trivial) error, but completely clueless about the possible causes. I
I started to think about tracking changes in complex object graph in disconnected application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.