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

  • SEARCH
  • Home
  • 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 7637423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:56:07+00:00 2026-05-31T07:56:07+00:00

I have read some reference’s and i think i understood the usage the new

  • 0

I have read some reference’s and i think i understood the usage the “new” keyword in OOP languange (but i don’t!)

So i can’t understand this line of code, i got it from the tut’s in thenewboston :

ourBrow = (WebView) findViewById(R.id.wvBrowser);
ourBrow.setWebViewClient(new OurViewClient());

So the setWebViewClient(); method requires a WebViewClient in it’s params. The think that i don’t understand is, why we need to add the “new” keyword here?
NOTE that OurViewClient() is a class that we made and extended by WebViewClient.

Sorry, if my way to ask the question is making you confuse, coz i also confuse now @_@

Thanks All! 😀

NOTE : English is not my native languange, so sorry if i made some mistake’s 😀

  • 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-31T07:56:09+00:00Added an answer on May 31, 2026 at 7:56 am

    OurViewClient is the class that you made. OurViewClient() is a constructor for that class which takes 0 parameters. And the setWebViewClient() method requires a WebViewClient instance as its parameter.

    So the new operator effectively allocates a new instance of the OurViewClient class and then invokes the default 0-parameter constructor on that instance, returning the created object. Using new is the only way you can create an instance of an Object in Java, barring more advanced topics like reflection or using things like sun.misc.Unsafe and also some exceptions centered around built-in types/autoboxing (e.g. String s = "str"; and Integer num = 7;).

    Note that the following code is essentially equivalent to the code that you have:

    WebViewClient client = new OurViewClient();
    ourBrow = (WebView) findViewById(R.id.wvBrowser);
    ourBrow.setWebViewClient(client);
    

    Also note that the following are invalid:

    WebViewClient client = OurViewClient();  //can't invoke a constructor without using 'new'
    WebViewClient client = OurViewClient;    //can't assign the class
    WebViewClient client;  //valid syntax, but 'client' will be null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read some articles on POCO in the enttity framework but still don't
I have read through some tutorials about javascript prototypal inheritance patterns but I am
I am new to ASP.net MVC architecture. I have read in some articles that
I've read some documentation on how Adaboost works but have some questions regarding it.
I've read some docs about the .NET Garbage Collector but i still have some
I have read that some of the JVMs out there can optimize code execution
Follow up to This I have also read up on some other questions but
Long title but hopefully I can explain what I am after. I have read
I have read some posts on here about not mixing parameters when passing into
I have read some posts about this topic and the answers are comet, reverse

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.