Search code examples
androidunreachable-statement

Unreachable Statement in url


When I enter the database url, I got error Unreachable Statement

String url= "http://www.example.com/php.php";

This is my code:

        @Override
        public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
            View view = inflater.inflate(R.layout.tab_2,container,false);
            return view;


            String url= "http://www.example.com";

            warga = (RecyclerView) view.findViewById(R.id.warga);
            LinearLayoutManager llm = new LinearLayoutManager(getActivity());
            llm.setOrientation(LinearLayoutManager.VERTICAL);
            warga.setLayoutManager(llm);

            requestQueue = Volley.newRequestQueue(getActivity().getApplicationContext());

            list_data = new ArrayList<HashMap<String, String>>();

            stringRequest = new StringRequest(Request.Method.GET, url, new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    Log.d("response ", response);
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONArray jsonArray = jsonObject.getJSONArray("warga");

Solution

  • return view; code is not executed after return. That's all. return should be very last thing you do in your method. Nothing can be done after return
    this is Java very-basics.