Private Sub CommandButton1_Click() Dim val As String val = Cells(5, "G").Value Dim fast As Boolean fast = True Dim last As Boolean last = False Dim values As String values = "" Dim lent As Integer lent = Len(val) Dim result As String result = "" For i = 1 To lent If Cells(5, "G").Characters(Start:=i, Length:=1).Font.Color = vbRed Then If fast Then values = "<span style='color:#dd0062;'>" & "" & Mid(val, i, 1) fast = False last = True Else last = True values = values & "" & Mid(val, i, 1) End If
Different IDEs short cut key for System.out.println() in Netbeans, Eclipse, JDeveloper and intellij Short cut on Eclipse Type syso and press Ctrl+space Short cut on Netbeans Type sout and press Tab key Short cut on intellij Type sout and press Tab key Short cut on JDeveloper Type sop and press Ctrl+Enter
Object oriented analysis (OOA) Object oriented design (OOD) 1. Start with the simple object which can be abstracted into individual classes. 2. Identify all the classes in the requirement specification. 3. Identify the commonalities between all or small groups of classes. Do not force fit generalization where it doesn’t make sense. 4. Keep all the data members private or protected 5. Identify all the member variables and methods the class should have 6. Ensure that the class is fully independent of other classes and contains all the necessary attributes and methods. 7. The methods in the class should be abstract. 8. Don't use the procedural code into a class for the methods in the class. 9. Inherit and extend classes from the base classes when require. 10. Define the "Has-A" or "Uses-A" relationships among the classes Object oriented programming (OOP) Software development life cycles Entity relationship model (ER model / ER diagrams)...
how to install apps in windows phone without internet how to install xap file in windows phone How to download apps without using the store Solution: Windows phone application extension type is .XAP files. Download the application in your computer or create your won application with .xap file Send it to phone or SD card via USB Open your app store in your windows phone Go to option in app store Highlighted option
Handle http request from web browser. Creating own server like tomcat, No need to deploy the code .Program will run with out any server. Getting url parameter and sending response. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.net.InetSocketAddress; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; public class Test { public static void main(String[] args) throws Exception { HttpServer server = HttpServer.create(new InetSocketAddress(8002), 0); server.createContext("/test", new MyHandler()); server.setExecutor(null); // creates a default executor server.start(); }
Understanding Threads A thread is a single sequence of executable code within a larger program. All the programs shown so far in this book have used just one thread — the main thread that starts automatically when you run the program. However, Java lets you create programs that start additional threads to perform specific tasks. Understanding the Thread class The Thread class lets you create an object that can be run as a thread in a multi-threaded Java application. The Thread class has quite a few constructors and methods, but for most applications you only need to use the ones listed in Table. Constructors and Methods of the Thread Class Constructor Explanation Thread() The basic Thread constructor without ...
Similar question: How to read XML file in Java java dom parser java sax parser listing all the files in a directory in java Solution: Config.xml <note> <id>1</id> <description>Files</description> <path>C://x</path> <id>2</id> <description>Files</description> <path> C://y </path> </note>
Create Web Project from Maven: Open CMD > Type the commend mvn archetype:generate -DgroupId={project-packaging} -DartifactId={project-name} - DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false example : mvn archetype:generate -DgroupId=com.Webapp -DartifactId=WebApp -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
Capacity : Capacity is the N umber of element HashMap can contain. initial capacity is the capacity at the time the hash table is created default initial capacity (16) capacity increased (2 power n) , where n- number of elements load factor : Defines threshold of HashMap. When re-sizing will occur of HashMap. The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased. default load factor (.75) fail-fast :
Hashmap: Hash table implements Map interface Hash table permits null values and the null key HashMap class is equivalent to Hashtable, except that it is unsynchronized and permits nulls It does not guarantee that the order will remain constant over time constant-time performance for the operations (get, put and remove) Time complexity - O(1) for get, put and remove (Learn About capacity , load factor and fail-fast ) It is not synchronized How to make Hashmap Synchronize Map m = Collections.synchronizedMap(new HashMap(...)); Exapmle : import java.util.*; public class HashMapEx{
Java has a final keyword that we can use it in three places. Final variable When you use final with a variable, it creates a constant whose value can’t be changed once it has been initialized. Similarly final can be used to create final methods and final classes. For Example: final int i=10; final File f=new File(); final ClassName; Final methods A final method is a method that can’t be overridden by a subclass. To create a final method, you simply add the keyword final to the method declaration. For example: public class SpaceShip { public final int getVelocity() { return this.velocity; } }
import java.util.Scanner; public class MergeSort { public static void sort(int[] a, int low, int high) { int N = high - low; if (N <= 1) return; int mid = low + N/2; // recursively sort sort(a, low, mid); sort(a, mid, high); // merging two sorted sub-arrays int[] temp = new int[N]; int i = low, j = mid; for (int k = 0; k < N; k++) { if (i == mid) temp[k] = a[j++]; ...
import java.util.regex.Matcher; import java.util.regex.Pattern; public class GetSum { public static void main(String[] args) { String s = " 1ima7 j1 1hh1 0ttr1dfg10 "; Pattern p = Pattern.compile("[0-9]"); Matcher m = p.matcher(s); int sum = 0; while (m.find()) { sum += Integer.parseInt(m.group()); } System.out.println(sum); }
Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object. Benefits of inheritance reuse of methods reuse of fields of parent class We can add new methods and fields Syntax public class className extends ParentclassName { //methods and fields }
Polymorphism (from the Greek meaning "having multiple forms") Polymorphism means one thing in many form. an object to have more than one form. Polymorphism is capability of one object to behave in multiple ways. There are following types of polymorphism : Static polymorphism (compile time) function overloading :- Method Overloading is a feature that allows more than two methods having same name in a class with different parameters. Example: public class Calculator{ void add(int a,int b) { System.out.println(a+b); } void add(int a,int b,int c) { System.out.println(a+b+c); }
Abstraction is the process is used to hide certain details and only show the essential features of the object. It is class level design that hiding the complexity of the implementation and offered by an API / design / system, in a sense simplifying the 'interface' to access the underlying implementation. Example: public class Employee { private String name; private String address; private int sal; public Employee(String name, String address, int sal) { this.name = name; this.address = address; this.sal = sal; }
Creating Custom Exceptions Here we are going to learn how to create your own exception. The Throwable hierarchy As you know, you use the try/catch statement to catch exceptions, and the throw statement to throw exceptions. Each type of exception that can be caught or thrown is represented by a different exception class. What you might not have realized is that those exception classes use a fairly complex inheritance chain, as shown in Figure :
Encapsulation Encapsulation is a mechanism of binding the data and function into a single unit. Encapsulation essentially has both information hiding and implementation hiding. Encapsulation provides a way for abstraction. Example: class Encapsulation { //Restrict direct access, hiding Data private int a; private int b; public void setA(int a){ this.a=a; } public void setB(int b){ this.b=b; } //hiding implementation public int sum(){ int total=a+b; // Other Implementation return total; } }
Class A class is a blueprint or prototype from which objects are created. Class that contains data type, Object, function methods, properties, Classes and constructor. Example: For example our college, Our college contain different different classes and classes contain student. Programming Language Example: class MyClass{ String name= ""; String address= ""; int age= 0; void setName(String name) { this.name = name; } void setAddress(String address) { this.address = address; } void setAge(int age) { this.age = age; } void print() { System.out.println(name +" "+Address+" "+age); } }
Object Object is representative of the class and is responsible for memory allocation of its data members and member functions.An object is a real world entity having attributes (State / data type) and behaviors (functions). An object can be considered a "thing" that can perform a set of related activities. The set of activities that the object performs defines the object behavior. Example: In our class room, All students are an individual Object. They have different name and color. Programming Language Example: All are the Different different object int a=10; float b1=20.10f; String s1="Name"; MyClass x;
JavaScript Data Types Following are the javascript data type : String, Number, Boolean, Array, Object. Example: Number var length = 10; String var Name = "Soma"; Array var country = ["India", "China", "USA"]; Object / JSON var name = {firstName:"Nikita", lastName:"Camon"};
Object-oriented programming (OOP) is a programming paradigm based on the concept of "objects". Re-usability is the main concept of Oops. There are few major principles of object-oriented paradigm. If any programming Language supports this principles that programming language called Object-oriented programming. Below are object oriented programming concepts : 1. Object Read More about Object http://theprogrammersfirst.blogspot.in/2016/07/java-object-concept.html
Input Format The first line contains T, denoting the number of test cases. First line of each test case has two integers N, denoting the number of nodes in the graph and M, denoting the number of edges in the graph. The next M lines each consist of three space-separated integers x,y,r , where x and y denote the two nodes between which the undirected edge exists, r denotes the length of edge between these corresponding nodes. The last line has an integer , S denoting the starting position. Example: 1 4 4 1 2 24 1 4 20 3 1 3 4 3 12 1
/* Node is defined as : class Node int data; Node left; Node right; */ static Node lca(Node root,int v1,int v2) { //Decide if you have to call rekursively //Samller than both if(root.data < v1 && root.data < v2){ return lca(root.right,v1,v2); } //Bigger than both if(root.data > v1 && root.data > v2){ return lca(root.left,v1,v2); }
Swapping subtrees of a node means that if initially node has left subtree L and right subtree R, then after swapping left subtree will be R and right subtree L. import java.io.*; import java.util.*; public class Solution {
Similar Questions: Prime Numbers Java Example Print prime numbers between 1 and given number using for loop //check to see if the number is prime boolean isPrime = true; for(int j=2; j < 10 ; j++){ if(10 % j == 0){ isPrime = false; break; } ...
A queue is a collection that is based on the first-in-first-out (FIFO) policy. dequeue() - get an item from the queue. enqueue() - insert item into the queue.
A stack is a collection that is based on the last-in-first-out (LIFO) policy. push() - push an item into stack. pop() - get an item and remove it from the top.
Java programming source code class ReverseNumber { public static void main(String args[]) { System.out.println("Enter the number to reverse"); int n=54321, int reverse = 0; while( n != 0 ) { reverse = reverse * 10; reverse = reverse + n%10; n = n/10; } System.out.println("Reverse number is "+reverse); } }
Definition: A linked list is a recursive data structure that is either empty (null) or a reference to a node having a generic item and a reference to a linked list. Structure: Node record: class Node<Item> { Item item; Node next; }
Computing the value of arithmetic expressions like this one: ( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) Which means multiply 4 by 5, add 3 to 2, multiply the result, and then add 1, you get the value 101. But how does the Java system do this calculation? We can address the essential ideas by writing a Java program that can take a string as input (the expression) and produce the number represented by the expression as output. Dijkstra's Two stack Algorithm for Expression Evaluation public class ExpressionEvaluation { public static void main(String args[]){ Stack<String> ops = new Stack<String>(); Stack<Double> ops = new Stack<Double>();
/* Insert Node at the beginning of a linked list head pointer input could be NULL as well for empty list */ /* Node is defined as class Node { int data; Node next; } */ Node Insert(Node head,int x) { Node node=new Node(); node.data=x; node.next=head; return node; }
Similar Question: Print List of Armstrong number. Solution: class armstrong { public static void main(String args[]) { int s=0,n=153,m,d; m=n; while(n>0)
Related Question: How to zip a folder? AngularJs / JavaScript to download a file using web service. Solution: @GET @Path("/report/download/file/{filename : .+}") @Produces(MediaType.APPLICATION_OCTET_STREAM) public Response downloadFilebyPath(@PathParam("filename") String fileName) {
Lot of time JVM takes care of all garbage collector object. If your java program hold any system resources like (Calendar, File, Thread, Display properties many more) that time you should implement finalize method.
1 The following example shows how regular expression could be used with the @Path annotation. @Path("users/{username: regular expression}") Example: @Path("users/{username: [a-zA-Z][a-zA-Z_0-9]}") following URL: http://example.com/users/hello 2 The @PathParam annotation example @Path("/users/{username}") public class User { @GET @Produces("text/xml") public String getUser(@PathParam("username") String userName) { System.out.println(userName); } }
/* Insert Node at the end of a linked list head pointer input could be NULL as well for empty list Node is defined as class Node { int data; Node next; } */
/* Print elements of a linked list class Node { int data; Node next; } */ void Print(Node head) { while(head != null){ System.out.println(head.data); head = head.next; } }
Merge two linked list that are aleady sorted and return a new sorted list. Implement this method : Node MergeLists(Node list1, Node list2){ // your code here } Solution:
java.lang.Exception: Error getting all Data! - No bean named 'transactionManager' is defined com.Parameters(Resource.java:46) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) java.lang.reflect.Method.invoke(Method.java:601) org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81) org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:151) org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:172) org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherPr...