What is the guys name that play in blade?

His name is Wesley Snipes



Can't scaffold controller in Visual Studio 2013 U4

When I try scaffold controller with view in ASP.NET MVC 5 project with MVC 5 Controller with views, using Entity Framework menu item for model School (Nola.Core.Models.Education) and DB context ApplicationDbContext (Data) I get error:



A configuration for type 'Nola.Core.Models.Users.ApplicationUser' has already been added. To reference the existing configuration use the Entity<T>() or ComplexType<T>() methods.


All relations of models writen with Entity Framework Fluent API and apply in methodOnModelCreatingof DB context like this



modelBuilder.Configurations.Add(new ApplicationUserConfiguration());


When I remove one configuration item then get error on next configuration. If comment all configurations, then get error says EF can't find relations for some models.



I use Visual Studio Ultimate 2013 Update 4 with all updated NuGet packages. You can get project from here https://github.com/beta-tank/nola/tree/Develop in Develop branch.



P.S. I have tried many methods from Scaffolding controller doesn't work with visual studio 2013 update 2 (IDbSet, Web.config, reinstall packages and etc) but nothing helps.





order of execution of static method

public class Sample {

public void method()
{
System.out.println("normal hai");
}
public static void method1()
{
System.out.println("static hai");
}
public static void main(String[] args) {
Sample s = null;
s.method1();
s.method();
}
}


and the output is:



Exception in thread "main" java.lang.NullPointerException
at com.csvfile.sample.main(Sample.java:22)

static hai


Why has the order changed? It should output:



static hai
Exception in thread "main" java.lang.NullPointerException
at com.csvfile.sample1.main(Sample.java:22)


Answers

The issue you have is that the Exception is printed to System.err while your code prints to System.out.



So, without a badly named class (PascalCase please) we can do:



public static void main(String[] args) throws Exception {
final System system = null;
system.out.println("Odd");
System.out.println(system.toString());
}


And the output I get is:



Exception in thread "main" java.lang.NullPointerException
Odd
at com.boris.testbench.App.main(App.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)


So they're actually interleaved. i.e. the order of the output is undefined as there are two output streams being printed to the console.



Changing the code to:



public static void main(String[] args) throws Exception {
final System system = null;
system.err.println("Odd");
System.err.println(system.toString());
}


Produces the desired result.



You could also catch the exception and print it to System.out to achieve the same effect:



public static void main(String[] args) throws Exception {
final System system = null;
system.out.println("Odd");
try {
System.out.println(system.toString());
} catch (RuntimeException ex) {
ex.printStackTrace(System.out);
}
}


P.S. I'm sure you know this, but you should never call a static method on an instance of the class. You should always call the static method on the class itself. So in your example, you should always do:



public static void main(String[] args) {
sample1 s = new sample1();
s=null;
sample1.method1();
s.method();
}


Answers

That is because the exception is printed to STDERR and System.out.println() is printed to STDOUT and both streams are not synchronized.



If you call it a second time the order can change.



Answers

This is because out and err are two different output streams. However, both of them print on console. So you do not see them as different streams. Try the below code and check output.



for (int i = 0; i < 10; i++) {
System.out.println(i);
System.err.println(i);
}


Answers

Just a good to know thing in Java:



In Java there are several types of init fileds:
let`s see an example:



public class HunarianEngineer{

static{
System.out.println("1.This is a static block, called when the JVM pull in the class first time ever");
}

{
System.out.println("2.This is an instance block, runs before constructor");
}

public HungarianEngineer(){
System.out.println("3.I`m a constructor");
}

}//EndOfClass


Read more about them:
https://docs.oracle.com/javase/tutorial/java/javaOO/initial.html
or here:



http://www.thejavageek.com/2013/07/21/initialization-blocks-constructors-and-their-order-of-execution/





↑このページのトップヘ