[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Programming Languages-Other

19K

Solutions

19K

Contributors

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. Thousands of different programming languages have been created, mainly in the computer field, and many more still are being created every year. The description of a programming language is usually split into the two components of syntax (form) and semantics (meaning). Some languages are defined by a specification document (for example, the C programming language is specified by an ISO Standard), while other languages (such as Perl) have a dominant implementation that is treated as a reference. Some languages have both, with the basic language defined by a standard and extensions taken from the dominant implementation being common.

Share tech news, updates, or what's on your mind.

Sign up to Post

try{
			
			previouslyTaken = new DataDAO().testForPkgPreviouslyTaken(this....., TimeStamp);//gives true or false boolean value
		}
		catch (XYZExceptionException xyze)
		{
			if(xyze.getMessage().contains("999"))
			{
				LOGGER.error("item is PreviouslyTaken due to aa", xyze);
				errorCodes.add(XYZConstants.PREVIOUS_TAKEN_EXISTS);				
			}
			else if(xyze.getMessage().contains("888"))
			{
				LOGGER.error("item is PreviouslyDumped due to bb", xyze);
				errorCodes.add(XYZConstants.PREVIOUSLY_DUMPED);
			}
			else
			{
				throw new XYZException(xyze);
			}	
			return ;
		}
		LOGGER.info("previouslyTaken indicator from DB {}",previouslyTaken); //coming false t me
		
		if(!previouslyTaken){
		processIt();
		else
		LOGGER.info("item taken or dumped so update status to new)

Open in new window


i have above code in a method.

i never saw if else inside a catch in earlier.

why some one use if else inside catch
when the catch is thrown as try block simply return true or false

when it has 999 or 888 etc value in the xyze exception

please advise
0
CompTIA Cloud+
LVL 12
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Hi,

I am working on an iOS application (in nativescript) that needs to get and post some data to an API in the background each 5 minutes. Now it seems that iOS is closing my application so I took a look at the long running tasks section of https://docs.nativescript.org/core-concepts/ios-runtime/how-to/BackgroundExecution but I fail to see how I should configure an interval now.

Also while it works correctly on the simulator (not thinking about the interval) with the debug fetch command, I can't get it to work correctly on a real device.
0
Hi,

I have got
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResul

Open in new window

with these codes
            List<HouseData> houseList = new List<HouseData>();
            try
            {
                using (SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["Mssqlconn3"].ConnectionString))
                {
                    using (SqlCommand sqlCmd = new SqlCommand("SELECT cast(ROW_NUMBER() OVER (ORDER BY house_id ASC) as int) serial_id, house_id, rent_type, house_name, area, area_unit2, clicked_times, area_unit, area_size, isnull(construct_area_size,0) construct_area_size, isnull(request_times,0) request_times, release_period_from, CONVERT(varchar,register_date,105) register_date,CONVERT(varchar,upd_date,105) upd_date, address1, address2, price, price_curr, ltrim(rtrim(cast(raised_by_user_id as varchar))) raised_by_user_id FROM house_tab where isnull(raised_by_user_id,0)=@raiser and isnull(deleted,'')<>'Y'", sqlConn))
                    

Open in new window

0
MQ under glassfish called imqdbroker not running when i double click on windows laptop.
path is
C:\Program Files\glassfish-4.0\mq\bin
i am not able to open default hosts under jms host to see that same mq that is supposed to be started
Please advise
MQ_glasfish.png
MQ_glasfish_2.png
0
hi,

I build one stateless session bean example with presentation tier html inddex page and web tier servlet within ejb web project then business tier in the ejb project


<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<html>
    <head>
        <title>TODO supply a title</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <form action="ConverterServlet" method="POST">
              <input type="number" name="value"></br>
              <select name="type">
                    <option value="C2F">celcius to fahrenheit</option>
                    <option value="F2C">fahrenheit  to celcius</option>
              </select></br>
              <input type="submit" value="Convert">
        </form>
            
    </body>
</html>

Open in new window


do i not need to add close tags for input html element
<input type="submit" value="Convert">

also do i not need to ad begin tag for </br>

please advise

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package servlet;

import bean.ConverterBeanLocal;
import bean.ConverterBeanLocal.ConvertType;
import java.io.IOException;
import java.io.PrintWriter;

Open in new window

0
Need a python script to copy yesterday files to a destination location and gzip them in destination directory
0
one registerPhone flow goes through 30 stored procedures. Each stored proc connecting database individually and taking 100 milli seconds to connect.

so 30 multipled by 100 total 3000 milli seconds wasted due to this.

can i make all 30 stored procedures into one call so that only one database connection happens for 100 milli seconds

Like to save those 3000 milli seconds when i can do only with 100 milli seconds

Please advise
0
hi, i can get postman to POST to create a VM but using pycharm encountered this error.

code 1: obtain a token
==========================================================================
import requests
url = "https://IP/silvan/apigateway/v1.0/"
get_apis = "apis_include_throttles"

##API URLs
get_token_url = "https://iam-apigateway-proxy.domain.com/v3/auth/tokens"

create_volume_url = "https://evs.sitc-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/volumes"
delete_volume_url = "https://evs.stic-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/volumes/"
create_vm_url = "https://ecs.sitc-1.domain.com/v2/6d321dd88c7143ba8d6daf3e15f14be9/servers"



##Images Dictionary
images = {
    "Ubuntu 18.10": "5313ace4-4573-404b-abc6-8548ed14c4f7",
    "RHEL7.5-40G": "aa9d05f3-cb90-4776-9c02-617a9906b271",
    "WindowsServer2016WithGUI": "c54d05fa-5ad8-425e-be56-e60ede395230",
    "Windows10Pro": "29caef55-0617-4813-8a17-cb0bef19de16",
    "RHEL7.5": "c5ccd8a7-d8f3-4a4c-91c3-9d93303aee58",
    "Ubuntu16.04LTS": "3f8948fd-c108-48db-9951-1d617e8e5b03",
    "image-kvm-euler": "298e2912-5a7a-4178-8ac4-b260712d514c",
    "image-ManageOne": "80d9b0ee-a5b3-42fe-99ed-fc32c57da5b3",
    "esight_image": "e1e94234-f3e7-4793-8bdb-0cef9e3194cf"
}


def get_token():
    body = {
        "auth": {
            "identity": {
                "methods": [
                    "password"
                ],
                "password": {
                    "user": {
    …
0
How to read particular text (like empno,name,salary,etx) from scanned or image file and store in db using python with any one deep learning library (like tensorflow, pytorch,etc)

pls. provide some sample code and which one we can use for this concepts
0
i am learning to use Python / pycharm / PIP to provision 1000 VM through a script to call the  API but i don't know how to start doing it.
 
What is the proper way to install python with IDE, Pycharm and PIP for Windows 10?
Where to obtain the python template code to provision 1000 VMs for example for me to modify the flavours, image, types, servers, network?
How to put the digital token on the script and where & how to execute the script if is connected thr VPN client from my PC?
How to generate a private key from the python script as well?


I managed to use web POSTMAN from google chrome to test calling the API to provision some VM as stated in below.

1. Connected to Private Cloud Fusion Cloud 6.3 from Web POSTMAN

2. Obtained a digital token
POST => https://iam-apigateway-proxy.domain.com/v3/auth/tokens

{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"domain": {
"name": "XXX"
},
"name": "XXX",
"password": "XXX"
}
}
},
"scope": {
"project": {
"id": "XXX",
"domain": {
"name": "XXX"

3. Provisioned System Volume
POST => https://evs.domain.com/v2/cd088007d3b84e7fa894478e6fe667c4/volumes

{ "volume":
{
"size": 60,
"availability_zone": "az0.dc0",
"volume_type": "ssd",
"name":"volume1",
"multiattach": false,
"imageRef":"ca9384bd-5d78-49ce-a4c3-6d90d77c623c"
}
}

4. Provisioned VM  
POST => https://ecs.domain.com/v2/cd088007d3b84e7fa894478e6fe667c4/servers
{
"server": {
"flavorRef": …
0
Why Diversity in Tech Matters
LVL 12
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Hi Experts

Could you point what must to be done to make a PowerBuilder 6.5 project to be used on PowerBuilder 7.0?

I saw that "workspace"  must to be used but how to make the old  libraries to enter on it...


Thanks in advance!
0
Hello

This is Azizah Alqahtani

I just sent you email like this bellow and you response to give you the python code ..


Could you please help me to solve this problem,

I have to convert a python code to a Java code

Or rewrite the code with the same idea ?


The code is about one type of substitution cipher ?

If you can , I will send you the assignment page and my friend’s answer in python..


Regards..
Assignment1Python.zip
0
Hi Experts,

there are two approached to pass sheet names vaue
1st approach:

JRXlsExporter exporter = new JRXlsExporter(); exporter.setParameter( JRXlsAbstractExporterParameter.SHEET_NAMES, new String[] {"first","second","third"} ); 

Open in new window


cant we pass this value as parameter in java?

this way(1st approach) i am unable to follow because i am sheduling report for a specificdate. and passing few parameter inputs as well for the same report.

sample:
Util.getParamString(stringBuilder, "GENERATEDON", Date);//similarly few more params i am passing

Open in new window


2nd approach:

iam setting in the report properties like below(2nd approach): Property Name = "net.sf.jasperreports.export.xls.sheet.names.all"

 Property Value = "first/second/third"

is there any chance to pass this property value as dynamic.?

I have tried like below as not works for me

<line> 
<reportElement x="0" y="-1" width="1" height="1"> 
<propertyExpression name="net.sf.jasperreports.export.xls.sheet.name"><![CDATA[$F{course_name}]]></propertyExpression> 
</reportElement> 
</line>

Open in new window

1
Constructors are not inherited:
The sub class cannot inherit constructors from its super class. Consider the following example:
1
2
3
4
5
6
7
8
9
10
11
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 
public class Sub extends Super {
 
}
We can create a new instance of Super like this:
1
Super super = new Super(“Hello”);   //OK
But we cannot do the same for the Sub class:
1
Sub sub = new Sub(“Hello”); //Compile error, since constructor is not inherited
The solution is to write a constructor for the sub class and call the super’s constructor, for example:
1
2
3
4
5
6
public class Sub extends Super {
 
    public Sub(String text) {
        super(text);
    }
}

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i wrote as below

package SuperSub;
public class Super {
    protected String text;
 
    public Super(String text) {
        this.text = text;
    }
}
 

Open in new window


package SuperSub;
public class Sub extends Super {
	//Super super = new Super(“Hello”);
}

Open in new window


i am getting error in line 2 of Sub class
Implicit super constructor Super() is undefined for default constructor. Must define an explicit constructor
package SuperSub;
public class Sub extends Super {

	public Sub(String text) {
		super(text);
		// TODO Auto-generated constructor stub
	}
	//Super super = new Super(“Hello”);
}

Open in new window

above is fine though not sure why i cannot just have Sub empty class?
Please advise
0
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        this.test();
}

Open in new window

why above code is not working
i see error as below at line 21,15
Syntax error, insert "}" to complete ClassBody

Please advise
0
The super keyword:
In Java, the superkeyword is used to access members of the super type from the sub type. For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Super {
    protected void bar() {
        System.out.println("Super.bar()...");
    }
 
}
 
public class Sub extends Super {
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
        super.bar();
        this.bar();
    }
}
Here, we can see that both classes have a method called bar() (overriding). Therefore, if we want to invoke the super’s version of the bar() method, the super keyword is used.
 

Open in new window


super with this example not working for me
package SuperThis;
public class Sub extends Super {
	public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    //public void test() {
       // super.bar();
        //this.bar();
   // }
        
}

Open in new window


above code giving below error
Cannot use super in a static context
Cannot use this in a static context

how to fix this
package SuperThis;

public class Test {
public static void main(String[] args) {
	 Sub sub=new Sub();
	    sub.test();
}
}

Open in new window


Super.bar()...
Sub.bar()...


does it need separate class for this to test
package SuperThis;
public class Sub extends Super {
	/*public static void main(String[] args) {
		  super.bar();
	      this.bar();
	}*/
    public void bar() {
        System.out.println("Sub.bar()...");
    }
 
 
    public void test() {
       super.bar();
       this.bar();
    }
  
    	// Sub sub=new Sub();
    	 //   sub.test();
    
        test();
}

Open in new window

how to test in same Sub class

above gives error at line 20
Multiple markers at this line
      - This method requires a body instead of a
       semicolon
      - Return type for the method is missing
      - Duplicate method test() in type Sub

please advise
0
One interesting point with inheritance in Java is that, we can use the super type when creating a new object of the sub type.
Suppose Car is the parent class of the Truck class as shown in the following code:
1
2
3
4
5
6
7
8
9
public class Car {
    public void move() {
    }
}
 
public class Truck extends Car {
    public void load() {
    }
}
It’s legal to write:
1
Car vehicle = new Truck();
The rule is: the type on the left side can be super type of the actual object in the right side. Note that the only methods we can invoke are the ones declared in the super type, for example:
1
vehicle.move(); //okay, since Truck inherits Car
Also note that, if the subclass declares a new method, we cannot invoke it using the super type reference:
1
vehicle.load(); // compile error

Open in new window


IF i take parent type and object as child i am getting error.

but when i cast it as below no error

can you please advise why no error

package ParentSuperTypeObjectSubType;

public class TestClass {
	public static void main(String[] args) {
		Car vehicle = new Truck();
		vehicle.move(); //okay, since Truck inherits Car
		vehicle.load(); // compile error
		((Truck) vehicle).load(); // ok
	}

}

Open in new window


below also worked fine if i cast
package ParentSuperTypeObjectSubType;

public class TestClass {
      public static void main(String[] args) {
            Car vehicle = new Truck();
            Truck car = new Car();  // Compile error
            Truck car = (Truck) new Car();  // Compile error
            vehicle.move(); //okay, since Truck inherits Car
            vehicle.load(); // compile error
            ((Truck) vehicle).load(); // ok
      }

}



is above is upcast or downcast
i confuse those similar name?
0
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java

i tried as below

package MultipleInheritance;
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}


package MultipleInheritance;
public class C extends A, B {
    public void methodC() {
        foo();
    }
}

Open in new window


on C class i get below error

Multiple markers at this line
      - Syntax error on token "extends", delete this token
      - Syntax error, insert "ClassBody" to complete
       ClassDeclaration
      - Syntax error, insert "}" to complete Block

can you please advise what above error means

it did not say "multiple inheritance of state not allowed"

Please advise
0
6. Multiple inheritance of state is not allowed:
Remember that Java does not allow a class inherits two or more classes directly. To understand why multiple inheritance is not allowed, consider the following example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
public class A {
    public void methodA() {
 
    }
 
    public void foo() {
 
    }
}
 
 
public class B {
    public void methodB() {
 
    }
 
    public void foo() {
 
    }
}
Suppose that we want to write a class C that extends both A and B like this:
1
2
3
4
5
public class C extends A, B {
    public void methodC() {
        foo();
    }
}
As you can see, both A and B has a method called foo(), so which foo() method the class C invokes exactly? from A or B? This case is ambiguous hence Java does not allow.
 
7. Multiple inheritance of type is allowed:
This means Java does allow multiple inheritance between interfaces. For example:
1
2
3
4
5
6
7
8
9
10
11
public interface X {
    public void methodX();
}
 
public interface Y {
    public void methodY();
}
 
public interface Z extends X, Y {
    public void methodZ();
}
This is allowed because interfaces do not have concrete methods, thus there is no ambiguity.
Likewise, we can have a class implements multiple interfaces:
1
2
3
4
5
6
7
public class Sub implements X, Y, Z {
    public void methodX() { }
 
    public void methodY() { }
 
    public void methodZ() { }
}

Open in new window


if both Interface X and Interface Y has same method called methodAB what happens?



Open in new window

0
Become a Certified Penetration Testing Engineer
LVL 12
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Let’s look at the constructor of the Truckclass - it can access the protected field numberOfWheels and the default field name. However, it cannot access the private field age. We can write:
1
2
3
Truck truck = new Truck();
truck.start();
truck.move();
But the Java compiler will complain if we try to invoke the private method test():
1
truck.test();   // COMPILE ERROR, since private member is not inherited

Open in new window


https://www.codejava.net/java-core/the-java-language/12-rules-and-examples-about-inheritance-in-java


i supposed to put below code in which class Car or Truck or Moveable?


public class Truck extends Car {
    public Truck() {
        numberOfWheels = 8;
        name = "Truck";
        age=10;
    }
    
    Truck truck = new Truck();
    truck.start();
    truck.move();
    
}

Open in new window




or as below

public class Car extends Vehicle {
	String name;
	protected int age;
    //protected int age;
    protected int numberOfWheels = 4;
    
    public void move() {
        System.out.print("Moving by engine...");
    }

	@Override
	public void start() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub
		
	}
	
	/*Truck truck = new Truck();
	truck.start();
	truck.move();*/
}

Open in new window


below i cannot put as it is interface

public interface Moveable {
    public void start();
 
    public void stop();
 
    public void move();
}

Open in new window


please advise
0
Don’t use a for loop with an index (or counter) variable if you can replace it with the enhanced for loop (since Java 5) or forEach (since Java 8). It’s because the index variable is error-prone, as we may alter it incidentally in the loop’s body, or we may starts the index from 1 instead of 0.
Consider the following example that iterates over an array of Strings:
1
2
3
4
5
String[] names = {"Alice", "Bob", "Carol", "David", "Eric", "Frank"};
 
for (int i = 0; i < names.length; i++) {
    doSomething(names[i]);
}
As you can see, the index variable i in this for loop can be altered incidentally which may cause unexpected result. We can avoid potential problems by using an enhanced for loop like this:
1
2
3
for (String aName : names) {
    doSomething(aName);
}
This does not only remove potential issues but also make the code cleaner and more succinct. 

Open in new window


how is it possible to do for loop index modifycation?

how enhanced for loop is diferent from for each loop?

is there any case where we still has to use traditional for loop with index
please advise
0
public class CollectionsRef {
 
    private HashSet<Integer> numbers;
 
    public ArrayList<String> getList() {
 
        return new ArrayList<String>();
    }
 
    public void setNumbers(HashSet<Integer> numbers) {
        this.numbers = numbers;
    }
}
Look at the reference types which are collection implementation classes - this locks the code to work with only these classes HashSet and ArrayList. What if we want the method getList() can return a LinkedList and the method setNumbers() can accept a TreeSet?
The above class can be improved by replace the class references to interface references like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
public class CollectionsRef {
 
    private Set<Integer> numbers;
 
    public List<String> getList() {
        // can return any kind of List
     [b]   return new ArrayList<String>();[/b]
    }
 
    public void setNumbers(Set<Integer> numbers) {
        // can accept any kind of Set
        this.numbers = numbers;
    }
}

Open in new window


can we have generic List as return type to provide more flexibility to future changes to collection implementation?
https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
Please advise
0
Avoid Redundant Initialization (0-false-null)
It’s very unnecessary to initialize member variables to the following values: 0, false and null. Because these values are the default initialization values of member variables in Java. For example, the following initialization in declaration is unnecessary:
1
2
3
4
5
public class Person {
    private String name = null;
    private int age = 0;
    private boolean isGenius = false;
}
This is also redundant:
1
2
3
4
5
6
7
8
9
10
11
public class Person {
    private String name;
    private int age;
    private boolean;
 
    public Person() {
        String name = null;
        int age = 0;
        boolean isGenius = false;
    }
}
Therefore, if you know the default initialization values of member variables, you will avoid unnecessary explicit initialization. See more here:

Open in new window


i am not clear on below

This is also redundant:


does it mean initialization in the constructor as well apart from at class level

public Person() {
        String name = null;
        int age = 0;
        boolean isGenius = false;
    }
}

https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
Please advise
0
It’s a very bad idea to create an interface which is solely for declaring some constants without any methods. Here’s such an interface:
1
2
3
4
5
public interface Color {
    public static final int RED = 0xff0000;
    public static final int BLACK = 0x000000;
    public static final int WHITE = 0xffffff;
}
It’s because the purpose of interfaces is for inheritance and polymorphism, not for static stuffs like that. So the best practice recommends us to use an enum instead. For example:
1
2
3
public enum Color {
    BLACK, WHITE, RED
}
In case the color code does matter, we can update the enum like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public enum Color {
 
    BLACK(0x000000),
    WHITE(0xffffff),
    RED(0xff0000);
 
    private int code;
 
    Color(int code) {
        this.code = code;
    }
 
    public int getCode() {
        return this.code;
    }
}

Open in new window


what is the meaning of color code does not matter and updating like below?

In case the color code does matter, we can update the enum like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public enum Color {
 
    BLACK(0x000000),
    WHITE(0xffffff),
    RED(0xff0000);
 
    private int code;
 
    Color(int code) {
        this.code = code;
    }
 
    public int getCode() {
        return this.code;
    }
}

Open in new window

https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know

when we create special AppConstants class?
can there be interface just for constants?
please advise
0
String sql = "Insert Into Users (name, email, pass, address)";
sql += " values ('" + user.getName();
sql += "', '" + user.getEmail();
sql += "', '" + user.getPass();
sql += "', '" + user.getAddress();
sql += "')"[b][u];[/u][/b]

Open in new window

in above StringBuilder example why ; is not in double quotes?
https://www.codejava.net/coding/10-java-core-best-practices-every-java-programmer-should-know
https://www.w3schools.com/sql/sql_insert.asp

same question i have with StringBuilder as well
StringBuilder sbSql
    = new StringBuilder("Insert Into Users (name, email, pass, address)");
 
sbSql.append(" values ('").append(user.getName());
sbSql.append("', '").append(user.getEmail());
sbSql.append("', '").append(user.getPass());
sbSql.append("', '").append(user.getAddress());
sbSql.append("')");
 
String sql = sbSql.toString();


why we need to do toString only in case of StringBuilder

also what it mean by String builder not thread safe and string buffere thread safe

any example or link to prove this theory into practical?
Please advise
0

Programming Languages-Other

19K

Solutions

19K

Contributors

A programming language is a formal constructed language designed to communicate instructions to a machine, particularly a computer. Thousands of different programming languages have been created, mainly in the computer field, and many more still are being created every year. The description of a programming language is usually split into the two components of syntax (form) and semantics (meaning). Some languages are defined by a specification document (for example, the C programming language is specified by an ISO Standard), while other languages (such as Perl) have a dominant implementation that is treated as a reference. Some languages have both, with the basic language defined by a standard and extensions taken from the dominant implementation being common.