Connect with us

PROGRAMMING

Working with Java Anonymous Class

Published

on

<p>

Java Anonymous Class

Anonymous Inner Class are classes in java that have no name. It is mostly used when a local class is mostly needed to be used once.

However, Anonymous Inner Class just like normal class, can extend other classes but cannot extend a class and implement an Interface at the same time.

it can have access to local variables within the method or class it was declared. But other classes or methods can’t have access to it.

Some rules and other things involved in declaring an Anonymous class
1. Contructors are not declared inside Anonymous class.
1. Many methods can be declared inside an anonymous class

Look at the AnonymousInnerClassDemo below for more understanding. 

public class AnonymousInnerClassDemo {
 
     public static void main(String… args) {
        AnonymousInnerClassDemo anonymous =
            new AnonymousInnerClassDemo();
        anonymous.siteLogo();
    }

     //declaring an interface
  interface Logo {
        public void myLogo();
        public void churchLogo();
    }

      //this is a method inside the AnonymousInnerClassDemo Class
      public void siteLogo() {
     
          //this is an inner class inside method implementing the interface Logo
       class Graphics implements Logo {
         
            int width = 300;
            int height = 200;

            public void myLogo() {
                System.out.println(“The Width of the Logo is: ” + width);
            }
            public void churchLogo() {
                System.out.println(“The height of the Church Logo is: “+height+”n”);
            }
        }
     
      //calling the inner class Graphics
        Logo lg = new Graphics();
        lg.myLogo();
        lg.churchLogo();
     
        //Declaring the Anonymous inner class
        Logo otherDesign = new Logo() {
         
            public void myLogo() {
                System.out.println(“Other Design can be here”);
               }
            public void churchLogo() {
            System.out.println(“TOther Church Logo design can be here”);
            }
        };
     
        //calling the Anonymous Inner Class
        //There can be many methods inside the anonyous inner class
        otherDesign.myLogo();
        otherDesign.churchLogo();
     
   }   
}

Click to comment

Leave a Reply

Your email address will not be published.

PROGRAMMING

programming languages for web designing in 2020

Published

on

By

programming languages for web designing
<p>

programming languages for web designing.

Are you a newbie or a pro looking for programming languages for web designing? If so, you are at the best place to get all the information needed to become a web designer or developer.

Firstly, some people don’t know the deference between a web designer and a web developer especially newbies (that’s thoes new to the world of programming). Don’t bother, the detail of everything will be explained here.

And, at the end of this lessons, I will be dropping the simple codes used in the design of Facebook front page done with just HTML and CSS alone, for free. Enough of the stories, let’s go into details.

Difference between a web designer and a web developer

A web designer is a person that makes use of some tools like Photoshop to show the layout and the user interface of a website such as the colorations, placement of the buttons etc. They are limited to some web languages like HTML and CSS.

A web developer is a person that brings functionality to a website designed by a web designer. They makes use of HTML, CSS, JavaScript, jQuery, PHP, Python, Java etc.

Note: it will be advisable for anyone that wants to have a site like facebook.com, Yahoo.com and other professional website to go for web development instead of web designing because a web developer have almost all the knowledge of a web designer if not all, but a web designer have limited knowledge in coding a completely working site. And one can enroll into one of the top free online classes.

Programming languages for web designing

  1. HTML – HTML is a mark up language which stands for Hypertext Markup Language. It is used to design the web layout. It makes use of tags e.g … And must be saved with a .html extension.
  2. CSS – This is used to put beauty into the site. CSS (Cascade Stylesheet) is used to style up the web pages. It can be used externally, internally and inline.
  3. Javascript : In several areas of web creation, JavaScript is used. This language is used by web developers to add interactive features to their websites. User involvement is essential to your organization and JavaScript elements should be integrated into your design by your web developer.
  4. Python: Python is one of the most widely used and workable languages. For most of the website specifications, Python can build a system. Simple and clear syntax is used to help Web developers interact with and communicate to their customers. This language makes them easy. Pinterest and Instagram are some popular sites which use this language.
  5. SQL: SQL(Standard Query Language) is a database query language used to process vast numbers of data on your website. Through SQL, you can compile and cater for your web site to your target audience from various databases. This language is not used alone; it is instead combined with others to take advantage of your client database and the growth of your website.
  6. PHP: PHP is typically used on high-data websites or Destop and mobile applications. PHP is an open source language that can be updated easily to suit the company or website’s needs. Large websites such as Facebook and WordPress use PHP to handle and process their content.

Finally, in fulfillment of my early promise to drop the codes for Facebook login page with HTML and CSS only, the code is below.

<html>
	<head><title>FACEBOOK REGISTRATION</title>

<style>
.header{background-color:blue; height:110px; width:auto;}
.footer{background-color:white; height:150px; width:auto;}
form{position:relative; padding-top:10px; padding-right:50px;}
.content{height:600px; width:auto; background-color:#efefef;}
nav{display:inline-block;}
</style>
	</head>

	<body>
		<div class="header">
			<div class="column1of2">
				<div class="column20f2">
					<form>
						<table style="color:white">
							<tr><th></th><th>Emial or Phone</th>
							<th>Password</th></tr>
							<tr><th scope="row" width="900" rowspan="2"><h1>facebook</h1></th><td><input type="text/number" value="" placeholder=""></td>
							<td><input type="password" value="" placeholder=""></td>
							<td><input type="submit" name="login" value="login"></td></tr>
							<tr><!--th scope="row" width="900" rowspan="2">facebook</th--><td></td>
							<td><a href="">Forgotten Your Password</a></td></tr>
						</table>
					</form>
				</div>
			</div>


			<div class="content">

				<nav>
					<img src="images/me5.png" height=500px; width=800px;/></nav>
				<nav>
					<h2>Sign Up</h2>
					<p>It's free and always will be</p>
					<form>
						<input type="text" value="" placeholder="first name" size="28">
						<input type="text" value="" placeholder="surname" size="28"><p>
						<input type="text/number" value="" placeholder="mobile number or email address" size="60"><p>
						<input type="text/number" value="" placeholder="Re-enter mobile number or email address" size="60"><p>
						<input type="pasword" value="" placeholder="New Password" size="60"><p>
						Birethday<br>
						<input type="date" name="depart" /> <a href="">why do i have to provide my date of birth?</a><p>
						<input type="radio" name="" value="female"/>Female<input type="radio" name="" value="Male"/>Male
						<P>By clicking sign up,you have agree to our <a href="">Terms</a> and that you have read<br>Our <a href="">Data Policy,</a> including our <a href="">Cooker Use</a></p>
						<input type="submit" name="register" value="Sign Up">
					</form>
				</nav>
			</div>

		<div class="footer">
		</div>

	</body>
</html>
The result of Facebook login page in Programming languages for web designing with CSS and HTML

Continue Reading

PROGRAMMING

Java Variable

Published

on

By

<p>

Variables

Variable is a memory storage that serves as a placeholder for identifiers. Identifiers are then the name that is assigned to data that is meant for manipulation. When working with java variables, the datatype of a particular variables meant to be observed unless error will erupt.

Ways of declaring a variable:

[Datatype Variable_name = variable;]

Example: int a = 10; or 

String a,b,c;
a = “Tonna”;
b = “Romanus”;

Types of variable

Local Variables: These are variable that are inserted or defined inside any method in Java class and destroys when the method is completed.

Instance variables: These are variables that are inserted or initialized within a class but not inside a method. It can be called up by any method.

Class variables: These are variable that are initialized within a class, outside any method but with a static keyword. The main difference of Class Variable and. Instance variable is that Instance variable is static while Class variable is not.

Code:

 1
2
3
4
5
6
7
8
9
10
11
12
13
public class JavaVariables {

public static int age = 20; //this a class variable because it's is outside a method
public static String name = "Tonna"; //This is also a Class variable
public static void main(String[] args){

int a = 21; //this is a local variable

System.out.println(name + " is " + age + " years old");
System.out.println(name + " will soon turn " + a + " soon");

}
}


Output:

Tonna is 20 years old
Tonna will soon turn 21 soon

Continue Reading

Trending

Copyright © 2020